Refactored basic network code.