Implements cleaning up on peer connect and more