Improvement in the undo collector. Tests added.