cleaning up indexing code.