refactoring for rust and c++ subclasses.