Update code about xgmmsgid, xgmlabels and xgmthrid. Fix some bugs

I merged my fork with the latest commit from original Libetpan.
Fix condstore and some other stuff.