Heavy bugfixes.