Some general bugfixes.