Refactor prime sieve into separate methods.