Improvements to entity diffing code

Look at this PR for several examples