Fixed bug with undo and added windowing undo