Bug fixes with undo stack