Miscellaneous bugs discovered by test suite

Turns out the test suite's complaints were not inaccurate :)