More refactoring, nested templates