This is in preparation for having JMD dumper also support dump over TCP/IP. Also fix some bugs in dumping (especially over TCP/IP)