Minor refactoring in peer and trntsession code