Cleaned up client javascript, moved all connection handling logic into it's own class.