fix xmpp_state tracking and clean up
clean up some code