Bug fixes and improvements around indexing