logical fixes in templates