Tidying up the templates, making sure is valid XML