Rename inputs to .tmpl files
Move some more repeated code to util.tmpl