Optimize the generated C# code