Revert some of the later changes in XMPP and fix other parts