Update by Xincheng Fixed some bugs