include templates in app.js build and clean up some code