Major template refactoring.