Fixed arrayIndexOutOfBounds exceptions.