Reduced C++ version.