Delete elements then modify elements.
Remove unused ElementMapping class.

This class was throwing exceptions that were causing the document
modification events to fail, and it is unused.
More comments and remove early bailout.
Do a set comparison to check whether to actually update the set.