Fixing some bugs mikelietz found.

JERK.