Add extra logging to code generation and fix 'enabled' flag.