coverity fixes

Hi.
I've fixed some of those coverity bugs that you've send, but some I believe are not correct and are just result of coverity bad analysis.