fixed bugs in hg