fixed some of the handshaking bugs