adapted to new ffi convention of haste