Replaced Miller-Rabin primality test with my own primality checker, which turned out to be more efficient