Peer manager

This might look as a tweak salad, but mostly the intention was to code main functionality of the PeerManager. Later pushes will be a little more dedicated.