Added refinement flag to the C++ API, crashes after refinement though