Moved indexing functionality into a separate script.