Pull request of a few bug fix from xm-1.5

Some bug fixes from Baoqiu and me.