Fixed typos.

Most of this code was written out on a whiteboard. The code reflects this.