Added handshake and query functions.