More template refactoring