Fix a couple bugs not caught by unit tests.