Reuse more code in the generator. Updated benchmarks.