Fixes to networking code