coverity fixes + bug fixes