Fix various minor issues pointed out by Coverity scanner.