undo implemented.  still needs some debugging.