Bugfixes and regression test.