Added some of the same compiler optimizations the C++ version gets