Big bunch of bugfixes.