Merge network related code and move into utils