Fix some C API issues