Cleaned up some variables in network.
ADded code to handle th case when the client disconnects and reconnects.