Restructured FFI code and fixed several major issues where :pointer was used but should be FFI::Struct.