Code generation!

Plus some other tweaks