template refactor cleanup