Coverity fixes

Fixes for Coverity issues:
- CID 1249633 (RESOURCE_LEAK)
- CID 1249632 (RESOURCE_LEAK)
- CID 1251453/1251454 (RESOURCE_LEAK)
- CID 1251445 (CHECKED_RETURN)
- CID 717142 (UNCAUGHT_EXCEPT)
- CID 717141 (UNCAUGHT_EXCEPT)
- CID 717156 (UNCAUGHT_EXCEPT)
- CID 717157 (UNCAUGHT_EXCEPT)
- CID 717163 (UNCAUGHT_EXCEPT)
- CID 1251575 (FORWARD_NULL)
- CID 1128395 - CID 1128398/CID 1128400 (USE_AFTER_FREE)

Other SCA fixes:
- don't check unsigned for < 0
- prefer ++op for non-primitive iterators
- silence cppcheck for std::remove misusage
-