Conversion to FFI for main file mostly done.