a lot of work on C ffi stuff