Instead of using Map.Entry we now use a dedicated class to hold key and value of a map entry. This avoids side effects from the implementation of Map.Entry. Replaced call to saveReferencedEntities with insertReferencedEntities which is simpler but equivalent since referenced entities always get only inserted, never updated. Removed superfluous methods resulting from that change.