Fix some issues pointed out by Coverity Scan