Massive speedup in codegen.

Switched from lists to sets in a bottleneck and back to reasonably performant
code. Also starting adding GCC scaffolding.