Fixing the network code

NOT DONE YET. THIS CODE IS CRAPPY.