Fixed a few bugs uncovered during integration tests.