Improve performance of prime generator.