Added more thorough comments. Funtionality related to chat moved from app.js to chatserver.js.