major template structure refactoring