Can you please file all of that in the bugzilla? I'm very reluctant to make changes to that code because I don't understand it, and don't have any easy way to run any regressions using test vectors, but I'll take a look at it.
One question, is this just Enveloped by itself, or is any actual use of XPath required (i.e. building with Xalan?) -- Scott