some bug fix after the recently merge from simmerge branch

I will delete simmerge branch after this merge.