replaced some C-functions with C++ wrappers