Fixed issues detected by Coverity Scan