network: clean up code