Improvements to the code generation to fix many errors.