Updated c++ port, not done