Refactored and commented $network.