cleanup code in network.py