Refactoring template files