Complete template refactoring.