Bug solving

Solve the bug where it does not allow undo and redo of a task that has
passed and a bug which might result in scrambling of data after certain
sorting.