a bunch of bugfixes.