Merge pull request #3658 from kgaillot/backport
Backport recent remote CIB cleanup and memory leak fix to 2.1