Coverity fixes
Coverity fixes + added comments