More code cleanup. Wrote a function in app.js safeSocketEmit, that checks for undefined before emitting. We should use this whenever we want to emit, since it is more robust and won't crash the server in edge cases (like if a socket disconnects randomly)