Initial C++ implementation.