added muxing of messages and debugged handshake