Bugfixes and test coverage.