fixed race conditions in handshakes