Fix a number of typos and bugs.