Fixed more issues found by scrutinizer