Replaced old C implementation with new C++ implementation.