Bugfix for beginUndo()

thx for reporting @Toshi