Undo/Redo added (with some minor bugs). Fixed #40