Various tweaks and bugfixes.