Fixed an undo and double click bug