Fixed bug in build_network.