Fixed bugs in handshake and connect requests.