fixed some bugs in the sample mh code.