Authenticate socket io connections

Authenticate socket io connections and make general improvements to
app's code