Further development on connectivity between peers. Some refactoring.