Refactored PrimeGenerator.