Fix issues detected by Coverity