Implemented client handshake, and did some corresponding debugging