Moved network code to network.rb
[cleanup]
Refactored network module to have all the networking code in there.