Revamp of peer.cpp code and modifications of peer.h reflecting those changes