Fix some quality flaws and improve code coverage.