diff --git a/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/interop/tools/RConnGetCCall.java b/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/interop/tools/RConnGetCCall.java
new file mode 100644
index 0000000000000000000000000000000000000000..d1843bda4ef40b23f6e3340e25745bacf0a19454
--- /dev/null
+++ b/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/interop/tools/RConnGetCCall.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.truffle.r.ffi.impl.interop.tools;
+
+import com.oracle.truffle.api.interop.ForeignAccess;
+import com.oracle.truffle.api.interop.TruffleObject;
+import com.oracle.truffle.r.runtime.data.RTruffleObject;
+
+public class RConnGetCCall implements RTruffleObject {
+    public static boolean isInstance(TruffleObject value) {
+        return value instanceof RConnGetCCall;
+    }
+
+    @Override
+    public ForeignAccess getForeignAccess() {
+        return RConnGetCCallMRForeign.ACCESS;
+    }
+
+}
diff --git a/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/interop/tools/RConnGetCCallMR.java b/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/interop/tools/RConnGetCCallMR.java
new file mode 100644
index 0000000000000000000000000000000000000000..77605f4c403f993ae9de6040cabe805c4285e872
--- /dev/null
+++ b/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/interop/tools/RConnGetCCallMR.java
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.truffle.r.ffi.impl.interop.tools;
+
+import java.io.IOException;
+
+import com.oracle.truffle.api.interop.MessageResolution;
+import com.oracle.truffle.api.interop.Resolve;
+import com.oracle.truffle.api.nodes.Node;
+import com.oracle.truffle.r.runtime.conn.RConnection;
+
+@MessageResolution(receiverType = RConnGetCCall.class)
+public class RConnGetCCallMR {
+    @Resolve(message = "EXECUTE")
+    public abstract static class RConnGetCCallExecute extends Node {
+        protected java.lang.Object access(@SuppressWarnings("unused") RConnGetCCall receiver, Object[] arguments) {
+            try {
+                return ((RConnection) arguments[0]).getc();
+            } catch (IOException ex) {
+                return -1;
+            }
+        }
+    }
+
+    @Resolve(message = "IS_EXECUTABLE")
+    public abstract static class RConnGetCCallIsExecutable extends Node {
+        protected Object access(@SuppressWarnings("unused") RConnGetCCall receiver) {
+            return true;
+        }
+    }
+
+}
diff --git a/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/nfi/TruffleNFI_Tools.java b/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/nfi/TruffleNFI_Tools.java
index 1d4d9c202ad4f136f2ea9e7d3536e98e6e2a672c..d9fa3345f779223257c442449a99c63ca25c2365 100644
--- a/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/nfi/TruffleNFI_Tools.java
+++ b/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/nfi/TruffleNFI_Tools.java
@@ -22,20 +22,17 @@
  */
 package com.oracle.truffle.r.ffi.impl.nfi;
 
-import java.io.IOException;
-
 import com.oracle.truffle.api.interop.ForeignAccess;
 import com.oracle.truffle.api.interop.InteropException;
 import com.oracle.truffle.api.interop.Message;
 import com.oracle.truffle.api.interop.TruffleObject;
 import com.oracle.truffle.api.nodes.Node;
 import com.oracle.truffle.r.ffi.impl.common.Generic_Tools;
-import com.oracle.truffle.r.ffi.impl.common.RFFIUtils;
 import com.oracle.truffle.r.runtime.RInternalError;
+import com.oracle.truffle.r.ffi.impl.interop.tools.RConnGetCCall;
 import com.oracle.truffle.r.runtime.conn.RConnection;
 import com.oracle.truffle.r.runtime.data.RLogicalVector;
 import com.oracle.truffle.r.runtime.data.RStringVector;
-import com.oracle.truffle.r.runtime.data.RTruffleObject;
 import com.oracle.truffle.r.runtime.env.REnvironment;
 import com.oracle.truffle.r.runtime.ffi.DLL;
 import com.oracle.truffle.r.runtime.ffi.DLL.DLLInfo;
@@ -46,24 +43,6 @@ import com.oracle.truffle.r.runtime.ffi.ToolsRFFI;
 public class TruffleNFI_Tools implements ToolsRFFI {
 
     private static class TruffleNFI_ToolsRFFINode extends Generic_Tools.Generic_ToolsRFFINode {
-        private interface RConnGetC {
-            int getc(RConnection conn);
-        }
-
-        private static class RConnGetCImpl implements RConnGetC, RTruffleObject {
-            @Override
-            public int getc(RConnection conn) {
-                RFFIUtils.traceUpCall("getc");
-                try {
-                    int r = conn.getc();
-                    RFFIUtils.traceUpCallReturn("getc", r);
-                    return r;
-                } catch (IOException ex) {
-                    return -1;
-                }
-            }
-        }
-
         private static boolean initialized;
 
         @Child private DLLRFFI.DLSymNode dysymNode = DLLRFFI.DLSymNode.create();
@@ -86,8 +65,8 @@ public class TruffleNFI_Tools implements ToolsRFFI {
             Node bind = Message.createInvoke(1).createNode();
             Node executeNode = Message.createExecute(1).createNode();
             try {
-                TruffleObject function = (TruffleObject) ForeignAccess.sendInvoke(bind, symbolHandle.asTruffleObject(), "bind", "((object): sint32): void");
-                ForeignAccess.sendExecute(executeNode, function, new RConnGetCImpl());
+                TruffleObject function = (TruffleObject) ForeignAccess.sendInvoke(bind, symbolHandle.asTruffleObject(), "bind", "(env, (object): sint32): void");
+                ForeignAccess.sendExecute(executeNode, function, new RConnGetCCall());
             } catch (InteropException t) {
                 throw RInternalError.shouldNotReachHere(t);
             }
diff --git a/com.oracle.truffle.r.ffi.processor/src/com/oracle/truffle/r/ffi/processor/FFIProcessor.java b/com.oracle.truffle.r.ffi.processor/src/com/oracle/truffle/r/ffi/processor/FFIProcessor.java
index e413931ca4d468f9fba2698305c89380133e0d49..a4623218d73a45941398777933459fb8fa86935f 100644
--- a/com.oracle.truffle.r.ffi.processor/src/com/oracle/truffle/r/ffi/processor/FFIProcessor.java
+++ b/com.oracle.truffle.r.ffi.processor/src/com/oracle/truffle/r/ffi/processor/FFIProcessor.java
@@ -341,12 +341,16 @@ public final class FFIProcessor extends AbstractProcessor {
                 return "uint8";
             case "int":
                 return "sint32";
+            case "long":
+                return "sint64";
             case "double":
                 return "double";
             case "void":
                 return "void";
             case "int[]":
                 return "[sint32]";
+            case "long[]":
+                return "[sint64]";
             case "double[]":
                 return "[double]";
             case "byte[]":
diff --git a/com.oracle.truffle.r.native/fficall/src/truffle_nfi/rffiutils.h b/com.oracle.truffle.r.native/fficall/src/truffle_nfi/rffiutils.h
index 72765550b53b2e4e08f39d1a3465ac32ce16c608..1997890c2b17c6cb45a7a324e35d37be5cd764f9 100644
--- a/com.oracle.truffle.r.native/fficall/src/truffle_nfi/rffiutils.h
+++ b/com.oracle.truffle.r.native/fficall/src/truffle_nfi/rffiutils.h
@@ -30,7 +30,7 @@
 #include <trufflenfi.h>
 
 extern void init_memory();
-extern void init_utils();
+extern void init_utils(TruffleEnv* env);
 
 // use for an unimplemented API function
 void *unimplemented(char *msg) __attribute__((noreturn));
diff --git a/com.oracle.truffle.r.native/library/tools/Makefile b/com.oracle.truffle.r.native/library/tools/Makefile
index bd62cb85150fc07d1b2c525e58b6811481f03501..9c415e7f92e967f064f4844ba8170c6043556189 100644
--- a/com.oracle.truffle.r.native/library/tools/Makefile
+++ b/com.oracle.truffle.r.native/library/tools/Makefile
@@ -65,7 +65,7 @@ $(OBJ)/%.o: $(GNUR_SRC)/%.c
 	$(CC) $(CFLAGS) $(INCLUDES) -c $< -o $@
 
 $(OBJ)/gramRd_nfi.o: $(SRC)/truffle_nfi/gramRd_nfi.c
-	$(CC) $(CFLAGS) $(FFI_INCLUDES) -c $< -o $@
+	$(CC) $(CFLAGS) $(FFI_INCLUDES) $(NFI_INCLUDES) -c $< -o $@
 
 $(OBJ)/gramRd_llvm.o: $(SRC)/truffle_llvm/gramRd_llvm.c
 	$(CC) $(CFLAGS) $(FFI_INCLUDES) $(SULONG_INCLUDES) -c $< -o $@
diff --git a/com.oracle.truffle.r.native/library/tools/src/truffle_nfi/gramRd_nfi.c b/com.oracle.truffle.r.native/library/tools/src/truffle_nfi/gramRd_nfi.c
index c5716bb4c39a020499f69b2c1d97ecc4edb3d2a1..db70c16af36dc2bf5c8f571fa2d5e8c9a4c1bcbb 100644
--- a/com.oracle.truffle.r.native/library/tools/src/truffle_nfi/gramRd_nfi.c
+++ b/com.oracle.truffle.r.native/library/tools/src/truffle_nfi/gramRd_nfi.c
@@ -21,10 +21,12 @@
  * questions.
  */
 #include "../gramRd_fastr.h"
+#include <trufflenfi.h>
 
 static int (*call_RConnGetC)(void *conn);
 
-void gramRd_nfi_init(void *closure) {
+void gramRd_nfi_init(TruffleEnv* env, void *closure) {
+	(*env)->newClosureRef(env, closure);
 	call_RConnGetC = closure;
 }