Fixes to make coverity work correctly