A series of bugfixes.