Fix a bug in sending messages. Change exceptions according to protocol.