Speed up predict() by fixing a type stability issue