Use named class for UndoPair.

Use specific, named class for UndoPair instead of generic Tuple2. This
makes analysis of heap dumps much easier because profilers let you inspect
memory consumption on per-class basis.

The UndoPair case class is defined in companion object to not hold an
outer pointer reference.
Merge pull request #3702 from gkossakowski/undoPairs

Use named class for UndoPair.