Fixed a couple of logic errors.