Optimize network code