fix some bugs in protect mode.