Bug fixes for the C API.