Some ffi cleanup

These commits try to clean and isolate the ffi api from the compilation engines