HFA: fix some bugs