Coverity Fixes

Same as #466 without cgi plugin changes