Implement typing interrupt and refactor switches
Refactor
Fix undo bugs