bug fixes to template