Added undo, redo, and smarter resizing