cleanup on ffi functions
out own implementation of error messages