That sounds extremely clever. Might actually be something interesting for google summer of code, isn't it? I'd actually be interested in using this in a proposal.