many bugfixes from coverage tests