Cleanup for converting documents to XML.