Fixed a couple of bugs I should never have committed