Fixed a memory leak.
Made a few more WebSocket methods thread-safe.
Improved doc-comments.