initial version of undo/redo.  Needs more testing.