Code generation restructured