Fix some bugs and typos