MOAR code generation (and a few fixes)