Frank Su: fix some bugs.