Misc Code generation fixes