more robust network handling.  fixes #6