Minor fixes and improvements to networking code