Fix C FFI to use *mut pointers correctly and update code.

This was found because of unused mut warnings.