Refactoring of templates