Adds a build script and completes package.json
Improves socket debug output and error handling