fix some more bugs detected by scrutinizer