bugfixes and small improvements