Impemented different version of prime number generation.  It fixes the problem but it appears to be slower.