Modularizing network related code