Refactor the network plugin