Fixed an issue causing an infinite undo loop.