bugfixes and minor improvements