Fixes to pass coverity. New improvements.