Fix typo and some bugs