Fixed infinite undo loops. (2014-07-31 update)