Fixed some bugs and typo