Move templating to own file