Refactor variable setup
Implement fold undo
Introduce linear history with redo command
Size limit and protect edges in history