Tidies up template structure