Started refactoring for move to c++