More bug fixes for protocol.  Added debug logging and option to flip debug on/off.