More fixes and improvements to networking code