Improve cache concurrency
Implements #1017
Merge remote-tracking branch 'upstream/master'
Merge pull request #1020 from emmanuel-keller/master

Bug fixes and improvement