Updating the XML conversion function & tidying up