Improvements to templating