Improved factor.c and primes.c