fix a few trivial bugs that shouldn't make much difference