Templating cleanup and organization