MODE-2153 Fixed the code which caused invalid reference counts when restoring versions. 

The underlying cause of the issue however, will be fixed as part of MODE-2156.