Corrected some bugs and typos