Several minor bugfixes.