Changed files to match the network protocoll and cleaned up the code.