more refactoring of templates.