Coverity fixes

Fix the issues found by Coverity Scan.