to_xml, and some added functionality