Partially fix stack overflow in factorization (sometimes)