Fixed some small bugs found when running all tests.