Some fixes for Coverity