Cleanup of code and removed useless commented debug statements
Intermediate step: added the sort field in the index