Fix errors when fooled by the cache behaviour

Rename `$index` to `$index_key` to fix other confusions