The WebSocket API can now natively handle exceptions.
Reorganized some code and commented things.