First draft of code generation