Backport some changes from OpenBazaar also import network_util module.