Add utility functions to translate R to C++ and collapse modular models into flat model.