Fixed bug indexes after delete, and sorting indexes after task retrieval