fix duplicate objects after restoring data from localStorage

This makes sure that the originals of changed entities get merged
into the base of the stack after restoring the data from JSON.
This is necessary, because the stack will only have elements for
the current viewport after a restart and previously *modified*
objects will now be falsely detected as *created* ones.

Also refactors to consistently use the property "version" and
removes some ineffective code.