small refactoring: moved some code to a new template class ('CompositeTemplate')