a few bug fixes to the indexing code.