Refactoring templates a little