Re-factor network code