Fixing some bugs and typos