Make additional optimizations, match C# speed