Fix index causing crashes