polished up some features of network_functions, almost done with main.