Bugfix (for undo in analysis mode) and improvements to Analysis mode