Added some pretty basic error handling and connection stuff that prevents server from crashing due to disconnections.

Haven't tested fully, but should close #10 finally