Moved some network functions into separate class