Fixes NPE and duplicate data error when accessing or publishing a past revision.
Merge branch 'release/2.1'