Templates refactoring to straighten syntax