fix some bugs after porting