Optimization ideas

I will create a separate thread to discuss opportunities to improve the generated code.