bugfixes from scrutinizer