Fix some index definitions, remove useless code