Refactoring to clean up responsibilities and structure in app.js.
Further cleanup.