templates structural refactoring