Reworking some of the templating logic