Various bugfixes.