Fix a mistake with index_list iteration/cleanup