Added performace optimizations to C#