Refactoring on quadratic sieve.