Converting to c++, still in progress and very unfinished