Fix issues found by Scrutinizer