Fixed a bug whereby if there was more than one element, only the first would be traversed
Dealing with other types of XML events by just forwarding them through
Fixing a race condition in the closing of the writer