fix some bugs caused by an encoding issue