Many coverity fixes