Added verification of broadcast response message size Added clearer handling of message types I'm sure there's a better way to do debug logging, but I don't really feel like adding a dependency on another module just for that.
Also moved things out to their own files and setup require()s to bring it all together.