Minor bug fixes and typos