lots of bugfixes, lots of tests.