Initial C++ port