Refactor templating to be more extensible