Refactor templating.