Fixes some issue with undo manager