Fix ArrayIndexOutOfBounds exception.