Move majority of code to xml_exporter.