Change algorithm for primes to Miller-Rabin.