fixed undo PreviousState and added functionality for disableUndo