fix some bugs in 2b597eb