Fixed various bugs and typos.