Lots of changes to integrate JID-based p2p connections #302
Changed to use better typing