Change undo to use array of commands