add cleanup functionality and check zmq.send return values. plus log on error