Fix insertion index errors