Fix problems with networking code