Further refactoring of templates