Refactor xmpp.js
Don't use global for
Refactor + add docs + solve bug #185