Fixed bug in build_network_from_db(), added comments.