General bug fixes and typos