Bug fixes and typos