Removed some duplication from app.js (unused code)
Removed more duplication from app.js by moving prevalidation of username, app and sessionid into own function
Removed some more duplication from app.js by making most functions use the prevalidation function of username, app, sess