Initial port to C++