Fix undo bug and time bug!