Fixing some of the coverity issues