Fix memory corruption in zmq mode