Factorize the Pattern Generator setup out in a separate function.