Small bug fix and some work towards undo/redo.