bugfixes and minor corrections