Bug fix for index generating.