Several bugfixes and a feature addition.