Fix the bugs appeared after last PR

Same here.