Refactored parts of the Index encoding.