Various coverity fixes