Fix issues found by scrutinizer