Cleanup and document the xml type routine