Fix problems reported in Coverity