Bugfixes. More tests.