fix bugs; add timeout handling in handshake; add destroy()