Massive bugfixes.