some adaptions to factored out C/C++ API