Fix issue #74

Fix Javascript error message on startup
Fix infinite loop when host disconnects.