Implement Undo/Redo for edit operations.

This closes #4.