Fixed the handshake to actually do a handshake, not tested yet.