Fixed some typos and error handling