Refactor the P2P code and migrate the current hand-rolled event-based networking code to libevent. Project lead: @theuni