Fixes to templating