Lots of bugfixes.