Seems my windows box does not handle pow(a, b, c) very well. Now we are wrapping all values in a gmpy mpz object and it seems my problems are solved.