Code beautification, improved packing for compression transport, and added fixes for error handling. 

JSON.stringify/base64 options are too verbose, packing as hex offers significant compression improvement.