Coverity fixes

A few issues identified by coverity.