first bunch of coverity fixes