Fix compatibility for C API and add docs