Fixed a few bugs caused by sloppy typing.