More robust zmq1 handshake and fixes for zmq3 support.