diff --git a/com.oracle.truffle.r.native/fficall/jni/src/arithmetic.c b/com.oracle.truffle.r.native/fficall/common/src/arithmetic.c
similarity index 100%
rename from com.oracle.truffle.r.native/fficall/jni/src/arithmetic.c
rename to com.oracle.truffle.r.native/fficall/common/src/arithmetic.c
diff --git a/com.oracle.truffle.r.native/fficall/jni/src/util.c b/com.oracle.truffle.r.native/fficall/common/src/util.c
similarity index 100%
rename from com.oracle.truffle.r.native/fficall/jni/src/util.c
rename to com.oracle.truffle.r.native/fficall/common/src/util.c
diff --git a/com.oracle.truffle.r.native/fficall/common/src/variable_defs.h b/com.oracle.truffle.r.native/fficall/common/src/variable_defs.h
new file mode 100644
index 0000000000000000000000000000000000000000..51a953eebea0dbcb77638803654078e662dd7d9e
--- /dev/null
+++ b/com.oracle.truffle.r.native/fficall/common/src/variable_defs.h
@@ -0,0 +1,96 @@
+/*
+ * This material is distributed under the GNU General Public License
+ * Version 2. You may review the terms of this license at
+ * http://www.gnu.org/licenses/gpl-2.0.html
+ *
+ * Copyright (c) 1995-2015, The R Core Team
+ * Copyright (c) 2003, The R Foundation
+ * Copyright (c) 2015, Oracle and/or its affiliates
+ *
+ * All rights reserved.
+ */
+#ifndef VARIABLE_DEFS_H_
+#define VARIABLE_DEFS_H_
+
+// The global variables that are assumed by the R FFI.
+// N.B. Some variables become functions in FastR, see RInternals.h
+
+/* Evaluation Environment */
+//SEXP R_GlobalEnv;
+SEXP R_EmptyEnv;
+//SEXP R_BaseEnv;
+//SEXP R_BaseNamespace;
+//SEXP R_NamespaceRegistry;
+
+//SEXP R_Srcref;
+
+/* Special Values */
+SEXP R_NilValue;
+SEXP R_UnboundValue;
+SEXP R_MissingArg;
+
+/* Symbol Table Shortcuts */
+SEXP R_Bracket2Symbol;   /* "[[" */
+SEXP R_BracketSymbol;    /* "[" */
+SEXP R_BraceSymbol;      /* "{" */
+SEXP R_ClassSymbol;     /* "class" */
+SEXP R_DeviceSymbol;     /* ".Device" */
+SEXP R_DevicesSymbol;     /* ".Devices" */
+SEXP R_DimNamesSymbol;   /* "dimnames" */
+SEXP R_DimSymbol;     /* "dim" */
+SEXP R_DollarSymbol;     /* "$" */
+SEXP R_DotsSymbol;     /* "..." */
+SEXP R_DropSymbol;     /* "drop" */
+SEXP R_LastvalueSymbol;  /* ".Last.value" */
+SEXP R_LevelsSymbol;     /* "levels" */
+SEXP R_ModeSymbol;     /* "mode" */
+SEXP R_NameSymbol;     /* "name" */
+SEXP R_NamesSymbol;     /* "names" */
+SEXP R_NaRmSymbol;     /* "na.rm" */
+SEXP R_PackageSymbol;    /* "package" */
+SEXP R_QuoteSymbol;     /* "quote" */
+SEXP R_RowNamesSymbol;   /* "row.names" */
+SEXP R_SeedsSymbol;     /* ".Random.seed" */
+SEXP R_SourceSymbol;     /* "source" */
+SEXP R_TspSymbol;     /* "tsp" */
+
+SEXP R_dot_defined;      /* ".defined" */
+SEXP R_dot_Method;       /* ".Method" */
+SEXP R_dot_target;       /* ".target" */
+SEXP R_NaString;	    /* NA_STRING as a CHARSXP */
+SEXP R_BlankString;	    /* "" as a CHARSXP */
+
+// Symbols not part of public API but used in FastR tools implementation
+SEXP R_SrcrefSymbol;
+SEXP R_SrcfileSymbol;
+
+// logical constants
+SEXP R_TrueValue;
+SEXP R_FalseValue;
+SEXP R_LogicalNAValue;
+
+// Arith.h
+double R_NaN;		/* IEEE NaN */
+double R_PosInf;	/* IEEE Inf */
+double R_NegInf;	/* IEEE -Inf */
+double R_NaReal;	/* NA_REAL: IEEE */
+int R_NaInt;	/* NA_INTEGER:= INT_MIN currently */
+
+// from Defn.h
+const char* R_Home;
+const char* R_TempDir;
+
+// various ignored flags and variables:
+Rboolean R_Visible;
+Rboolean R_Interactive;
+Rboolean R_interrupts_suspended;
+int R_interrupts_pending;
+Rboolean mbcslocale;
+Rboolean useaqua;
+char OutDec = '.';
+Rboolean utf8locale = FALSE;
+Rboolean mbcslocale = FALSE;
+Rboolean latin1locale = FALSE;
+int R_dec_min_exponent = -308;
+
+#endif /* VARIABLE_DEFS_H_ */
diff --git a/com.oracle.truffle.r.native/fficall/jni/Makefile b/com.oracle.truffle.r.native/fficall/jni/Makefile
index 3baea0dd10f4bae762429fbfeb66d91883999e7b..4d3e358b0a5327b3b5d971cc75821103ddeb43f9 100644
--- a/com.oracle.truffle.r.native/fficall/jni/Makefile
+++ b/com.oracle.truffle.r.native/fficall/jni/Makefile
@@ -29,22 +29,33 @@ ifneq ($(MAKECMDGOALS),clean)
 include $(TOPDIR)/platform.mk
 endif
 
-.PHONY: all clean
+.PHONY: all clean common_links
 
-OBJ = lib
+OBJ = ../lib
 SRC = src
-C_SOURCES := $(wildcard $(SRC)/*.c)
+C_LOCAL_SOURCES := $(wildcard $(SRC)/*.c)
 C_HDRS := $(wildcard $(SRC)/*.h)
 C_LIBNAME := librfficall$(DYLIB_EXT)
-C_OBJECTS := $(subst $(SRC),$(OBJ),$(C_SOURCES:.c=.o))
 C_LIB := $(TOPDIR)/../lib/$(C_LIBNAME)
 
+COMMON = ../common
+C_COMMON_SOURCES := $(notdir $(wildcard $(COMMON)/src/*.c))
+
+C_SOURCES = $(C_LOCAL_SOURCES) $($(C_COMMON_SOURCES)
+C_OBJECTS := $(subst $(SRC),$(OBJ),$(C_SOURCES:.c=.o))
+$(info C_SOURCES=$(C_SOURCES))
+$(info C_COMMON_SOURCE=$(C_COMMON_SOURCES))
+$(info C_OBJECTS=$(C_OBJECTS))
+
 JNI_INCLUDES = -I $(JAVA_HOME)/include -I $(JAVA_HOME)/include/$(JDK_OS_DIR)
 FFI_INCLUDES = -I$(TOPDIR)/include -I$(TOPDIR)/gnur/R-3.1.3/src/include -I$(TOPDIR)/include/R_ext
 
 INCLUDES := $(JNI_INCLUDES) $(FFI_INCLUDES)
 
-all: $(C_LIB)
+all: Makefile common_links $(C_LIB) 
+
+common_links:
+	$(foreach file,$(C_COMMON_SOURCES),ln -sf ../$(COMMON)/$(file) $(SRC)/$(file);)	
 
 $(C_LIB): $(OBJ) $(C_OBJECTS)
 	$(DYLIB_LD) $(DYLIB_LDFLAGS) -o $(C_LIB) $(C_OBJECTS)
@@ -60,3 +71,4 @@ $(OBJ)/%.E: $(SRC)/%.c $(TOPDIR)/include/Rinternals.h
 
 clean:
 	rm -rf $(OBJ) $(C_LIB)
+	$(foreach file,$(C_COMMON_SOURCES),rm -f $(SRC)/$(file);)	
diff --git a/com.oracle.truffle.r.native/fficall/jni/src/applic.c b/com.oracle.truffle.r.native/fficall/jni/src/Applic.c
similarity index 87%
rename from com.oracle.truffle.r.native/fficall/jni/src/applic.c
rename to com.oracle.truffle.r.native/fficall/jni/src/Applic.c
index f7229804c16182b81c5fd7ce38ff2f65fba2ee77..e95b1c3c8244f8a8b066f27d188060c29ab72b4f 100644
--- a/com.oracle.truffle.r.native/fficall/jni/src/applic.c
+++ b/com.oracle.truffle.r.native/fficall/jni/src/Applic.c
@@ -42,3 +42,10 @@ void Rdqagi(integr_fn f, void *ex, double *bound, int *inf,
 	    int *iwork, double *work) {
 	unimplemented("Rdqagi");
 }
+
+void vmmin(int n, double *x, double *Fmin,
+	   optimfn fn, optimgr gr, int maxit, int trace,
+	   int *mask, double abstol, double reltol, int nREPORT,
+	   void *ex, int *fncount, int *grcount, int *fail) {
+	unimplemented("vmmin");
+}
diff --git a/com.oracle.truffle.r.native/fficall/jni/src/finalizer.c b/com.oracle.truffle.r.native/fficall/jni/src/Connections.c
similarity index 71%
rename from com.oracle.truffle.r.native/fficall/jni/src/finalizer.c
rename to com.oracle.truffle.r.native/fficall/jni/src/Connections.c
index 9486719ca5b1cb5f95d501b4975b194e9803bba9..9114fdd120851cddb40075f9637b25a4f14c67a7 100644
--- a/com.oracle.truffle.r.native/fficall/jni/src/finalizer.c
+++ b/com.oracle.truffle.r.native/fficall/jni/src/Connections.c
@@ -20,28 +20,19 @@
  * or visit www.oracle.com if you need additional information or have any
  * questions.
  */
-#include "rffiutils.h"
-
-void init_finalizer(JNIEnv *env) {
-
-}
-
-
-void R_RegisterFinalizer(SEXP s, SEXP fun) {
 
-}
-void R_RegisterCFinalizer(SEXP s, R_CFinalizer_t fun) {
+#include "rffiutils.h"
+#include <R_ext/Connections.h>
 
+SEXP R_new_custom_connection(const char *description, const char *mode, const char *class_name, Rconnection *ptr) {
+	return unimplemented("R_new_custom_connection");
 }
 
-void R_RegisterFinalizerEx(SEXP s, SEXP fun, Rboolean onexit) {
-
+size_t R_ReadConnection(Rconnection con, void *buf, size_t n) {
+	return (size_t) unimplemented("R_ReadConnection");
 }
 
-void R_RegisterCFinalizerEx(SEXP s, R_CFinalizer_t fun, Rboolean onexit) {
-
+size_t R_WriteConnection(Rconnection con, void *buf, size_t n) {
+	return (size_t) unimplemented("R_WriteConnection");
 }
 
-void R_RunPendingFinalizers(void) {
-
-}
diff --git a/com.oracle.truffle.r.native/fficall/jni/src/alloc.c b/com.oracle.truffle.r.native/fficall/jni/src/Memory.c
similarity index 98%
rename from com.oracle.truffle.r.native/fficall/jni/src/alloc.c
rename to com.oracle.truffle.r.native/fficall/jni/src/Memory.c
index 33f20cc6266e86e6244bfdbe5555fde4911d48e1..c1e6b127cc820ce6e8d4750673129443edb29858 100644
--- a/com.oracle.truffle.r.native/fficall/jni/src/alloc.c
+++ b/com.oracle.truffle.r.native/fficall/jni/src/Memory.c
@@ -19,7 +19,8 @@ static void **tMemTable;
 // hwm of tMemTable
 static int tMemTableIndex;
 static int tMemTableLength;
-void init_alloc(JNIEnv *env) {
+
+void init_memory(JNIEnv *env) {
     tMemTable = malloc(sizeof(void*) * T_MEM_TABLE_INITIAL_SIZE);
     tMemTableLength = T_MEM_TABLE_INITIAL_SIZE;
     tMemTableIndex = 0;
diff --git a/com.oracle.truffle.r.native/fficall/jni/src/envir.c b/com.oracle.truffle.r.native/fficall/jni/src/Parse.c
similarity index 85%
rename from com.oracle.truffle.r.native/fficall/jni/src/envir.c
rename to com.oracle.truffle.r.native/fficall/jni/src/Parse.c
index c2e2e70ee1cd5b6dfd57edd42022dc44a32cb8a9..bf3b650784b4bc2d1cc41bd492645f7bd30e9f4c 100644
--- a/com.oracle.truffle.r.native/fficall/jni/src/envir.c
+++ b/com.oracle.truffle.r.native/fficall/jni/src/Parse.c
@@ -20,13 +20,9 @@
  * or visit www.oracle.com if you need additional information or have any
  * questions.
  */
-
 #include "rffiutils.h"
-#include <stdlib.h>
-
-#include <R_ext/Rdynload.h>
+#include <R_ext/Parse.h>
 
-DL_FUNC R_FindSymbol(char const *name, char const *pkg,
-		     R_RegisteredNativeSymbol *symbol) {
-    unimplemented("R_FindSymbol");
+SEXP R_ParseVector(SEXP x, int y, ParseStatus *z, SEXP w) {
+	return unimplemented("R_ParseVector");
 }
diff --git a/com.oracle.truffle.r.native/fficall/jni/src/rng.c b/com.oracle.truffle.r.native/fficall/jni/src/Random.c
similarity index 97%
rename from com.oracle.truffle.r.native/fficall/jni/src/rng.c
rename to com.oracle.truffle.r.native/fficall/jni/src/Random.c
index 71d0de688ebe6aa9a2dc682c096fe45af71e6cea..be1c5cabdda92f32717252d16f0e01a2f7bbc652 100644
--- a/com.oracle.truffle.r.native/fficall/jni/src/rng.c
+++ b/com.oracle.truffle.r.native/fficall/jni/src/Random.c
@@ -22,7 +22,7 @@
  */
 #include "rffiutils.h"
 
-void init_rng(JNIEnv *env) {
+void init_random(JNIEnv *env) {
 }
 
 void GetRNGstate() {
diff --git a/com.oracle.truffle.r.native/fficall/jni/src/register.c b/com.oracle.truffle.r.native/fficall/jni/src/Rdynload.c
similarity index 97%
rename from com.oracle.truffle.r.native/fficall/jni/src/register.c
rename to com.oracle.truffle.r.native/fficall/jni/src/Rdynload.c
index faec416d7cb454d7a24cbb98de5e1e3efe562728..98bb8fc3c5b74df1df31faebe145554ba0ebfe91 100644
--- a/com.oracle.truffle.r.native/fficall/jni/src/register.c
+++ b/com.oracle.truffle.r.native/fficall/jni/src/Rdynload.c
@@ -24,7 +24,7 @@ static jmethodID useDynamicSymbolsID;
 static jmethodID forceSymbolsID;
 static jmethodID setDotSymbolValuesID;
 
-void init_register(JNIEnv *env) {
+void init_dynload(JNIEnv *env) {
     DLLClass = checkFindClass(env, "com/oracle/truffle/r/runtime/ffi/DLL");
     JNI_PkgInitClass = checkFindClass(env, "com/oracle/truffle/r/runtime/ffi/jnr/JNI_PkgInit");
     DotSymbolClass = checkFindClass(env, "com/oracle/truffle/r/runtime/ffi/DLL$DotSymbol");
@@ -135,3 +135,7 @@ DL_FUNC R_GetCCallable(const char *package, const char *name) {
 	unimplemented("R_GetCCallable");
 }
 
+DL_FUNC R_FindSymbol(char const *name, char const *pkg,
+		     R_RegisteredNativeSymbol *symbol) {
+    unimplemented("R_FindSymbol");
+}
diff --git a/com.oracle.truffle.r.native/fficall/jni/src/Rinternals.c b/com.oracle.truffle.r.native/fficall/jni/src/Rinternals.c
new file mode 100644
index 0000000000000000000000000000000000000000..1470ae4f1b0373fec7e91f23df2ccce214a5cab5
--- /dev/null
+++ b/com.oracle.truffle.r.native/fficall/jni/src/Rinternals.c
@@ -0,0 +1,1298 @@
+/*
+ * Copyright (c) 2015, 2015, 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.
+ */
+#include "rffiutils.h"
+#include <string.h>
+
+// Most of the functions with a Rf_ prefix
+// TODO Lots missing yet
+
+static jmethodID Rf_ScalarIntegerMethodID;
+static jmethodID Rf_ScalarDoubleMethodID;
+static jmethodID Rf_ScalarStringMethodID;
+static jmethodID Rf_ScalarLogicalMethodID;
+static jmethodID Rf_allocateVectorMethodID;
+static jmethodID Rf_allocateArrayMethodID;
+static jmethodID Rf_allocateMatrixMethodID;
+static jmethodID Rf_duplicateMethodID;
+static jmethodID Rf_consMethodID;
+static jmethodID Rf_evalMethodID;
+static jmethodID Rf_findfunMethodID;
+static jmethodID Rf_defineVarMethodID;
+static jmethodID Rf_findVarMethodID;
+static jmethodID Rf_findVarInFrameMethodID;
+static jmethodID Rf_getAttribMethodID;
+static jmethodID Rf_setAttribMethodID;
+static jmethodID Rf_isStringMethodID;
+static jmethodID Rf_isNullMethodID;
+static jmethodID Rf_warningcallMethodID;
+static jmethodID Rf_warningMethodID;
+static jmethodID Rf_errorMethodID;
+static jmethodID Rf_NewHashedEnvMethodID;
+static jmethodID Rf_rPsortMethodID;
+static jmethodID Rf_iPsortMethodID;
+static jmethodID RprintfMethodID;
+static jmethodID R_FindNamespaceMethodID;
+static jmethodID Rf_GetOption1MethodID;
+static jmethodID Rf_gsetVarMethodID;
+static jmethodID Rf_inheritsMethodID;
+static jmethodID CADR_MethodID;
+static jmethodID TAG_MethodID;
+static jmethodID PRINTNAME_MethodID;
+static jmethodID CAR_MethodID;
+static jmethodID CDR_MethodID;
+static jmethodID SETCAR_MethodID;
+static jmethodID SETCDR_MethodID;
+static jmethodID SET_STRING_ELT_MethodID;
+static jmethodID SET_VECTOR_ELT_MethodID;
+static jmethodID RAW_MethodID;
+static jmethodID INTEGER_MethodID;
+static jmethodID REAL_MethodID;
+static jmethodID LOGICAL_MethodID;
+static jmethodID STRING_ELT_MethodID;
+static jmethodID VECTOR_ELT_MethodID;
+static jmethodID LENGTH_MethodID;
+static jmethodID Rf_asIntegerMethodID;
+//static jmethodID Rf_asRealMethodID;
+static jmethodID Rf_asCharMethodID;
+static jmethodID Rf_asLogicalMethodID;
+static jmethodID Rf_PairToVectorListMethodID;
+static jclass SEXPTYPEClass;
+static jmethodID gnuRCodeForObjectMethodID;
+static jmethodID NAMED_MethodID;
+static jmethodID DUPLICATE_ATTRIB_MethodID;
+static jmethodID iS4ObjectMethodID;
+static jclass RExternalPtrClass;
+static jmethodID createExternalPtrMethodID;
+static jmethodID externalPtrGetAddrMethodID;
+static jmethodID externalPtrGetTagMethodID;
+static jmethodID externalPtrGetProtMethodID;
+static jmethodID externalPtrSetAddrMethodID;
+static jmethodID externalPtrSetTagMethodID;
+static jmethodID externalPtrSetProtMethodID;
+
+void init_internals(JNIEnv *env) {
+	Rf_ScalarIntegerMethodID = checkGetMethodID(env, CallRFFIHelperClass, "Rf_ScalarInteger", "(I)Lcom/oracle/truffle/r/runtime/data/RIntVector;", 1);
+	Rf_ScalarDoubleMethodID = checkGetMethodID(env, CallRFFIHelperClass, "Rf_ScalarDouble", "(D)Lcom/oracle/truffle/r/runtime/data/RDoubleVector;", 1);
+	Rf_ScalarStringMethodID = checkGetMethodID(env, CallRFFIHelperClass, "Rf_ScalarString", "(Ljava/lang/String;)Lcom/oracle/truffle/r/runtime/data/RStringVector;", 1);
+	Rf_ScalarLogicalMethodID = checkGetMethodID(env, CallRFFIHelperClass, "Rf_ScalarLogical", "(I)Lcom/oracle/truffle/r/runtime/data/RLogicalVector;", 1);
+	Rf_consMethodID = checkGetMethodID(env, CallRFFIHelperClass, "Rf_cons", "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;", 1);
+	Rf_evalMethodID = checkGetMethodID(env, CallRFFIHelperClass, "Rf_eval", "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;", 1);
+	Rf_findfunMethodID = checkGetMethodID(env, CallRFFIHelperClass, "Rf_findfun", "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;", 1);
+	Rf_defineVarMethodID = checkGetMethodID(env, CallRFFIHelperClass, "Rf_defineVar", "(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V", 1);
+	Rf_findVarMethodID = checkGetMethodID(env, CallRFFIHelperClass, "Rf_findVar", "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;", 1);
+	Rf_findVarInFrameMethodID = checkGetMethodID(env, CallRFFIHelperClass, "Rf_findVarInFrame", "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;", 1);
+	Rf_getAttribMethodID = checkGetMethodID(env, CallRFFIHelperClass, "Rf_getAttrib", "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;", 1);
+	Rf_setAttribMethodID = checkGetMethodID(env, CallRFFIHelperClass, "Rf_setAttrib", "(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V", 1);
+	Rf_isStringMethodID = checkGetMethodID(env, CallRFFIHelperClass, "Rf_isString", "(Ljava/lang/Object;)I", 1);
+	Rf_isNullMethodID = checkGetMethodID(env, CallRFFIHelperClass, "Rf_isNull", "(Ljava/lang/Object;)I", 1);
+	Rf_warningMethodID = checkGetMethodID(env, CallRFFIHelperClass, "Rf_warning", "(Ljava/lang/String;)V", 1);
+	Rf_warningcallMethodID = checkGetMethodID(env, CallRFFIHelperClass, "Rf_warningcall", "(Ljava/lang/Object;Ljava/lang/String;)V", 1);
+	Rf_errorMethodID = checkGetMethodID(env, CallRFFIHelperClass, "Rf_error", "(Ljava/lang/String;)V", 1);
+	Rf_allocateVectorMethodID = checkGetMethodID(env, CallRFFIHelperClass, "Rf_allocateVector", "(II)Ljava/lang/Object;", 1);
+	Rf_allocateMatrixMethodID = checkGetMethodID(env, CallRFFIHelperClass, "Rf_allocateMatrix", "(III)Ljava/lang/Object;", 1);
+	Rf_allocateArrayMethodID = checkGetMethodID(env, CallRFFIHelperClass, "Rf_allocateArray", "(ILjava/lang/Object;)Ljava/lang/Object;", 1);
+	Rf_duplicateMethodID = checkGetMethodID(env, CallRFFIHelperClass, "Rf_duplicate", "(Ljava/lang/Object;)Ljava/lang/Object;", 1);
+	Rf_NewHashedEnvMethodID = checkGetMethodID(env, RDataFactoryClass, "createNewEnv", "(Lcom/oracle/truffle/r/runtime/env/REnvironment;Ljava/lang/String;ZI)Lcom/oracle/truffle/r/runtime/env/REnvironment;", 1);
+	RprintfMethodID = checkGetMethodID(env, CallRFFIHelperClass, "printf", "(Ljava/lang/String;)V", 1);
+	R_FindNamespaceMethodID = checkGetMethodID(env, CallRFFIHelperClass, "R_FindNamespace", "(Ljava/lang/Object;)Ljava/lang/Object;", 1);
+	Rf_GetOption1MethodID = checkGetMethodID(env, CallRFFIHelperClass, "Rf_GetOption1", "(Ljava/lang/Object;)Ljava/lang/Object;", 1);
+	Rf_gsetVarMethodID = checkGetMethodID(env, CallRFFIHelperClass, "Rf_gsetVar", "(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V", 1);
+	Rf_inheritsMethodID = checkGetMethodID(env, CallRFFIHelperClass, "Rf_inherits", "(Ljava/lang/Object;Ljava/lang/String;)I", 1);
+//	Rf_rPsortMethodID = checkGetMethodID(env, CallRFFIHelperClass, "Rf_rPsort", "(Lcom/oracle/truffle/r/runtime/data/RDoubleVector;II)", 1);
+//	Rf_iPsortMethodID = checkGetMethodID(env, CallRFFIHelperClass, "Rf_iPsort", "(Lcom/oracle/truffle/r/runtime/data/RIntVector;II)", 1);
+    CADR_MethodID = checkGetMethodID(env, CallRFFIHelperClass, "CADR", "(Ljava/lang/Object;)Ljava/lang/Object;", 1);
+    TAG_MethodID = checkGetMethodID(env, CallRFFIHelperClass, "TAG", "(Ljava/lang/Object;)Ljava/lang/Object;", 1);
+    PRINTNAME_MethodID = checkGetMethodID(env, CallRFFIHelperClass, "PRINTNAME", "(Ljava/lang/Object;)Ljava/lang/Object;", 1);
+    CAR_MethodID = checkGetMethodID(env, CallRFFIHelperClass, "CAR", "(Ljava/lang/Object;)Ljava/lang/Object;", 1);
+    CDR_MethodID = checkGetMethodID(env, CallRFFIHelperClass, "CDR", "(Ljava/lang/Object;)Ljava/lang/Object;", 1);
+    SETCAR_MethodID = checkGetMethodID(env, CallRFFIHelperClass, "SETCAR", "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;", 1);
+    SETCDR_MethodID = checkGetMethodID(env, CallRFFIHelperClass, "SETCDR", "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;", 1);
+	SET_STRING_ELT_MethodID = checkGetMethodID(env, CallRFFIHelperClass, "SET_STRING_ELT", "(Ljava/lang/Object;ILjava/lang/Object;)V", 1);
+	SET_VECTOR_ELT_MethodID = checkGetMethodID(env, CallRFFIHelperClass, "SET_VECTOR_ELT", "(Ljava/lang/Object;ILjava/lang/Object;)V", 1);
+	RAW_MethodID = checkGetMethodID(env, CallRFFIHelperClass, "RAW", "(Ljava/lang/Object;)[B", 1);
+	REAL_MethodID = checkGetMethodID(env, CallRFFIHelperClass, "REAL", "(Ljava/lang/Object;)[D", 1);
+	LOGICAL_MethodID = checkGetMethodID(env, CallRFFIHelperClass, "LOGICAL", "(Ljava/lang/Object;)[I", 1);
+	INTEGER_MethodID = checkGetMethodID(env, CallRFFIHelperClass, "INTEGER", "(Ljava/lang/Object;)[I", 1);
+	STRING_ELT_MethodID = checkGetMethodID(env, CallRFFIHelperClass, "STRING_ELT", "(Ljava/lang/Object;I)Ljava/lang/String;", 1);
+	VECTOR_ELT_MethodID = checkGetMethodID(env, CallRFFIHelperClass, "VECTOR_ELT", "(Ljava/lang/Object;I)Ljava/lang/Object;", 1);
+	LENGTH_MethodID = checkGetMethodID(env, CallRFFIHelperClass, "LENGTH", "(Ljava/lang/Object;)I", 1);
+	Rf_asIntegerMethodID = checkGetMethodID(env, CallRFFIHelperClass, "Rf_asInteger", "(Ljava/lang/Object;)I", 1);
+//	Rf_asRealMethodID = checkGetMethodID(env, CallRFFIHelperClass, "Rf_asReal", "(Ljava/lang/Object;)D", 1);
+	Rf_asCharMethodID = checkGetMethodID(env, CallRFFIHelperClass, "Rf_asChar", "(Ljava/lang/Object;)Ljava/lang/String;", 1);
+	Rf_asLogicalMethodID = checkGetMethodID(env, CallRFFIHelperClass, "Rf_asLogical", "(Ljava/lang/Object;)I", 1);
+	Rf_PairToVectorListMethodID = checkGetMethodID(env, CallRFFIHelperClass, "Rf_PairToVectorList", "(Ljava/lang/Object;)Ljava/lang/Object;", 1);
+	SEXPTYPEClass = checkFindClass(env, "com/oracle/truffle/r/runtime/gnur/SEXPTYPE");
+	gnuRCodeForObjectMethodID = checkGetMethodID(env, SEXPTYPEClass, "gnuRCodeForObject", "(Ljava/lang/Object;)I", 1);
+	NAMED_MethodID = checkGetMethodID(env, CallRFFIHelperClass, "NAMED", "(Ljava/lang/Object;)I", 1);
+	DUPLICATE_ATTRIB_MethodID = checkGetMethodID(env, CallRFFIHelperClass, "DUPLICATE_ATTRIB", "(Ljava/lang/Object;Ljava/lang/Object;)V", 1);
+	iS4ObjectMethodID = checkGetMethodID(env, CallRFFIHelperClass, "isS4Object", "(Ljava/lang/Object;)I", 1);
+	RExternalPtrClass = checkFindClass(env, "com/oracle/truffle/r/runtime/data/RExternalPtr");
+	createExternalPtrMethodID = checkGetMethodID(env, RDataFactoryClass, "createExternalPtr", "(JLjava/lang/Object;Ljava/lang/Object;)Lcom/oracle/truffle/r/runtime/data/RExternalPtr;", 1);
+	externalPtrGetAddrMethodID = checkGetMethodID(env, RExternalPtrClass, "getAddr", "()J", 0);
+	externalPtrGetTagMethodID = checkGetMethodID(env, RExternalPtrClass, "getTag", "()Ljava/lang/Object;", 0);
+	externalPtrGetProtMethodID = checkGetMethodID(env, RExternalPtrClass, "getProt", "()Ljava/lang/Object;", 0);
+	externalPtrSetAddrMethodID = checkGetMethodID(env, RExternalPtrClass, "setAddr", "(J)V", 0);
+	externalPtrSetTagMethodID = checkGetMethodID(env, RExternalPtrClass, "setTag", "(Ljava/lang/Object;)V", 0);
+	externalPtrSetProtMethodID = checkGetMethodID(env, RExternalPtrClass, "setProt", "(Ljava/lang/Object;)V", 0);
+}
+
+SEXP Rf_ScalarInteger(int value) {
+	TRACE("%s(%d)\n", value);
+	JNIEnv *thisenv = getEnv();
+	SEXP result = (*thisenv)->CallStaticObjectMethod(thisenv, CallRFFIHelperClass, Rf_ScalarIntegerMethodID, value);
+    return checkRef(thisenv, result);
+}
+
+SEXP Rf_ScalarReal(double value) {
+	JNIEnv *thisenv = getEnv();
+	SEXP result = (*thisenv)->CallStaticObjectMethod(thisenv, CallRFFIHelperClass, Rf_ScalarDoubleMethodID, value);
+    return checkRef(thisenv, result);
+}
+
+SEXP Rf_ScalarString(SEXP value) {
+	TRACE(TARG1, value);
+	JNIEnv *thisenv = getEnv();
+	SEXP result = (*thisenv)->CallStaticObjectMethod(thisenv, CallRFFIHelperClass, Rf_ScalarStringMethodID, value);
+    return checkRef(thisenv, result);
+}
+
+SEXP Rf_ScalarLogical(int value) {
+	TRACE(TARG1, value);
+	JNIEnv *thisenv = getEnv();
+	SEXP result = (*thisenv)->CallStaticObjectMethod(thisenv, CallRFFIHelperClass, Rf_ScalarLogicalMethodID, value);
+    return checkRef(thisenv, result);
+}
+
+SEXP Rf_allocVector3(SEXPTYPE t, R_xlen_t len, R_allocator_t* allocator) {
+    if (allocator != NULL) {
+	unimplemented("RF_allocVector with custom allocator");
+	return NULL;
+    }
+    TRACE(TARG2d, t, len);
+    JNIEnv *thisenv = getEnv();
+    SEXP result = (*thisenv)->CallStaticObjectMethod(thisenv, CallRFFIHelperClass, Rf_allocateVectorMethodID, t, len);
+    return checkRef(thisenv, result);
+}
+
+SEXP Rf_allocArray(SEXPTYPE t, SEXP dims) {
+	TRACE(TARG2d, t, dims);
+	JNIEnv *thisenv = getEnv();
+	SEXP result = (*thisenv)->CallStaticObjectMethod(thisenv, CallRFFIHelperClass, Rf_allocateArrayMethodID, t, dims);
+	return checkRef(thisenv, result);
+}
+
+SEXP Rf_alloc3DArray(SEXPTYPE t, int x, int y, int z) {
+	return unimplemented("Rf_alloc3DArray");
+}
+
+SEXP Rf_allocMatrix(SEXPTYPE mode, int nrow, int ncol) {
+	TRACE(TARG2d, mode, nrow, ncol);
+	JNIEnv *thisenv = getEnv();
+	SEXP result = (*thisenv)->CallStaticObjectMethod(thisenv, CallRFFIHelperClass, Rf_allocateMatrixMethodID, mode, nrow, ncol);
+	return checkRef(thisenv, result);
+}
+
+SEXP Rf_allocList(int x) {
+	unimplemented("Rf_allocList)");
+	return NULL;
+}
+
+SEXP Rf_allocSExp(SEXPTYPE t) {
+	return unimplemented("Rf_allocSExp");
+}
+
+SEXP Rf_cons(SEXP car, SEXP cdr) {
+	JNIEnv *thisenv = getEnv();
+	SEXP result = (*thisenv)->CallStaticObjectMethod(thisenv, CallRFFIHelperClass, Rf_consMethodID, car, cdr);
+    return checkRef(thisenv, result);
+}
+
+void Rf_defineVar(SEXP symbol, SEXP value, SEXP rho) {
+	JNIEnv *thisenv = getEnv();
+	(*thisenv)->CallStaticObjectMethod(thisenv, CallRFFIHelperClass, Rf_defineVarMethodID, symbol, value, rho);
+}
+
+void Rf_setVar(SEXP x, SEXP y, SEXP z) {
+    unimplemented("Rf_setVar");
+}
+
+SEXP Rf_dimgets(SEXP x, SEXP y) {
+	return unimplemented("Rf_dimgets");
+}
+
+SEXP Rf_dimnamesgets(SEXP x, SEXP y) {
+	return unimplemented("Rf_dimnamesgets");
+}
+
+SEXP Rf_eval(SEXP expr, SEXP env) {
+    JNIEnv *thisenv = getEnv();
+    SEXP result = (*thisenv)->CallStaticObjectMethod(thisenv, CallRFFIHelperClass, Rf_evalMethodID, expr, env);
+    return checkRef(thisenv, result);
+}
+
+SEXP Rf_findFun(SEXP symbol, SEXP rho) {
+	JNIEnv *thisenv = getEnv();
+	SEXP result = (*thisenv)->CallStaticObjectMethod(thisenv, CallRFFIHelperClass, Rf_findfunMethodID, symbol, rho);
+	return checkRef(thisenv, result);
+}
+
+SEXP Rf_findVar(SEXP symbol, SEXP rho) {
+	JNIEnv *thisenv = getEnv();
+	SEXP result =(*thisenv)->CallStaticObjectMethod(thisenv, CallRFFIHelperClass, Rf_findVarMethodID, symbol, rho);
+    return checkRef(thisenv, result);
+}
+
+SEXP Rf_findVarInFrame(SEXP symbol, SEXP rho) {
+	JNIEnv *thisenv = getEnv();
+	SEXP result =(*thisenv)->CallStaticObjectMethod(thisenv, CallRFFIHelperClass, Rf_findVarInFrameMethodID, symbol, rho);
+    return checkRef(thisenv, result);
+}
+
+SEXP Rf_getAttrib(SEXP vec, SEXP name) {
+	JNIEnv *thisenv = getEnv();
+	SEXP result = (*thisenv)->CallStaticObjectMethod(thisenv, CallRFFIHelperClass, Rf_getAttribMethodID, vec, name);
+	return checkRef(thisenv, result);
+}
+
+SEXP Rf_setAttrib(SEXP vec, SEXP name, SEXP val) {
+	JNIEnv *thisenv = getEnv();
+	(*thisenv)->CallStaticObjectMethod(thisenv, CallRFFIHelperClass, Rf_setAttribMethodID, vec, name, val);
+	return val;
+}
+
+SEXP Rf_duplicate(SEXP x) {
+	JNIEnv *thisenv = getEnv();
+	SEXP result = (*thisenv)->CallStaticObjectMethod(thisenv, CallRFFIHelperClass, Rf_duplicateMethodID, x);
+	return checkRef(thisenv, result);
+}
+
+R_xlen_t Rf_any_duplicated(SEXP x, Rboolean from_last) {
+	unimplemented("Rf_any_duplicated");
+	return 0;
+}
+
+SEXP Rf_duplicated(SEXP x, Rboolean y) {
+	unimplemented("Rf_duplicated");
+	return NULL;
+}
+
+void Rf_copyMostAttrib(SEXP x, SEXP y) {
+	unimplemented("Rf_copyMostAttrib");
+}
+
+Rboolean Rf_inherits(SEXP x, const char * klass) {
+    JNIEnv *thisenv = getEnv();
+    jstring klazz = (*thisenv)->NewStringUTF(thisenv, klass);
+    return (*thisenv)->CallStaticIntMethod(thisenv, CallRFFIHelperClass, Rf_inheritsMethodID, x, klazz);
+}
+
+Rboolean Rf_isReal(SEXP x) {
+    return TYPEOF(x) == REALSXP;
+}
+
+Rboolean Rf_isSymbol(SEXP x) {
+    return TYPEOF(x) == SYMSXP;
+}
+
+Rboolean Rf_isComplex(SEXP x) {
+    return TYPEOF(x) == CPLXSXP;
+}
+
+Rboolean Rf_isEnvironment(SEXP x) {
+    return TYPEOF(x) == ENVSXP;
+}
+
+Rboolean Rf_isExpression(SEXP x) {
+    return TYPEOF(x) == EXPRSXP;
+}
+
+Rboolean Rf_isLogical(SEXP x) {
+    return TYPEOF(x) == LGLSXP;
+}
+
+Rboolean Rf_isObject(SEXP s) {
+	unimplemented("Rf_isObject");
+	return FALSE;
+}
+
+SEXP Rf_install(const char *name) {
+	JNIEnv *thisenv = getEnv();
+	jstring string = (*thisenv)->NewStringUTF(thisenv, name);
+	SEXP result = (*thisenv)->CallStaticObjectMethod(thisenv, CallRFFIHelperClass, createSymbolMethodID, string);
+	return checkRef(thisenv, result);
+}
+
+Rboolean Rf_isNull(SEXP s) {
+	JNIEnv *thisenv = getEnv();
+	return (*thisenv)->CallStaticIntMethod(thisenv, CallRFFIHelperClass, Rf_isNullMethodID, s);
+}
+
+Rboolean Rf_isString(SEXP s) {
+	JNIEnv *thisenv = getEnv();
+	return (*thisenv)->CallStaticIntMethod(thisenv, CallRFFIHelperClass, Rf_isStringMethodID, s);
+}
+
+cetype_t Rf_getCharCE(SEXP x) {
+    // unimplemented("Rf_getCharCE");
+    // TODO: real implementation
+    return CE_NATIVE;
+}
+
+SEXP Rf_mkChar(const char *x) {
+	JNIEnv *thisenv = getEnv();
+	// TODO encoding, assume UTF for now
+	SEXP result = (*thisenv)->NewStringUTF(thisenv, x);
+	return checkRef(thisenv, result);
+}
+
+SEXP Rf_mkCharCE(const char *x, cetype_t y) {
+	unimplemented("Rf_mkCharCE");
+	return NULL;
+}
+
+SEXP Rf_mkCharLen(const char *x, int y) {
+	return unimplemented("Rf_mkCharLen");
+}
+
+SEXP Rf_mkCharLenCE(const char *x, int len, cetype_t enc) {
+	JNIEnv *thisenv = getEnv();
+	char buf[len + 1];
+	memcpy(buf, x, len);
+	buf[len] = 0;
+	// TODO encoding, assume UTF for now, zero terminated
+	SEXP result = (*thisenv)->NewStringUTF(thisenv, buf);
+	return checkRef(thisenv, result);
+}
+
+SEXP Rf_mkString(const char *s) {
+	JNIEnv *thisenv = getEnv();
+	jstring string = (*thisenv)->NewStringUTF(thisenv, s);
+	return ScalarString(string);
+}
+
+int Rf_ncols(SEXP x) {
+	unimplemented("Rf_ncols");
+	return 0;
+}
+
+int Rf_nrows(SEXP x) {
+	unimplemented("Rf_nrows");
+	return 0;
+}
+
+
+SEXP Rf_protect(SEXP x) {
+	return x;
+}
+
+void Rf_unprotect(int x) {
+	// TODO perhaps we can use this
+}
+
+void R_ProtectWithIndex(SEXP x, PROTECT_INDEX *y) {
+
+}
+
+void R_Reprotect(SEXP x, PROTECT_INDEX y) {
+
+}
+
+
+void Rf_unprotect_ptr(SEXP x) {
+	// TODO perhaps we can use this
+}
+
+#define BUFSIZE 8192
+
+static int Rvsnprintf(char *buf, size_t size, const char  *format, va_list ap)
+{
+    int val;
+    val = vsnprintf(buf, size, format, ap);
+    buf[size-1] = '\0';
+    return val;
+}
+
+
+void Rf_error(const char *format, ...) {
+	// This is a bit tricky. The usual error handling model in Java is "throw RError.error(...)" but
+	// RError.error does quite a lot of stuff including potentially searching for R condition handlers
+	// and, if it finds any, does not return, but throws a different exception than RError.
+	// We definitely need to exit the FFI call and we certainly cannot return to our caller.
+	// So we call CallRFFIHelper.Rf_error to throw the RError exception. When the pending
+	// exception (whatever it is) is observed by JNI, the call to Rf_error will return where we do a
+	// non-local transfer of control back to the entry point (which will cleanup).
+	char buf[8192];
+	va_list(ap);
+	va_start(ap,format);
+	Rvsnprintf(buf, BUFSIZE - 1, format, ap);
+	va_end(ap);
+	JNIEnv *thisenv = getEnv();
+	jstring string = (*thisenv)->NewStringUTF(thisenv, buf);
+	// This will set a pending exception
+	(*thisenv)->CallStaticObjectMethod(thisenv, CallRFFIHelperClass, Rf_errorMethodID, string);
+	// just transfer back which will cleanup and exit the entire JNI call
+	longjmp(*getErrorJmpBuf(), 1);
+
+}
+
+void Rf_warningcall(SEXP x, const char *format, ...) {
+	char buf[8192];
+	va_list(ap);
+	va_start(ap,format);
+	Rvsnprintf(buf, BUFSIZE - 1, format, ap);
+	va_end(ap);
+	JNIEnv *thisenv = getEnv();
+	jstring string = (*thisenv)->NewStringUTF(thisenv, buf);
+	(*thisenv)->CallStaticObjectMethod(thisenv, CallRFFIHelperClass, Rf_warningcallMethodID, x, string);
+}
+
+void Rf_warning(const char *format, ...) {
+	char buf[8192];
+	va_list(ap);
+	va_start(ap,format);
+	Rvsnprintf(buf, BUFSIZE - 1, format, ap);
+	va_end(ap);
+	JNIEnv *thisenv = getEnv();
+	jstring string = (*thisenv)->NewStringUTF(thisenv, buf);
+	(*thisenv)->CallStaticObjectMethod(thisenv, CallRFFIHelperClass, Rf_warningMethodID, string);
+}
+
+void Rprintf(const char *format, ...) {
+	char buf[8192];
+	va_list(ap);
+	va_start(ap,format);
+	Rvsnprintf(buf, BUFSIZE - 1, format, ap);
+	va_end(ap);
+	JNIEnv *thisenv = getEnv();
+	jstring string = (*thisenv)->NewStringUTF(thisenv, buf);
+	(*thisenv)->CallStaticObjectMethod(thisenv, CallRFFIHelperClass, RprintfMethodID, string);
+}
+
+/*
+  REprintf is used by the error handler do not add
+  anything unless you're sure it won't
+  cause problems
+*/
+void REprintf(const char *format, ...)
+{
+	// TODO: determine correct target for this message
+	char buf[8192];
+	va_list(ap);
+	va_start(ap,format);
+	Rvsnprintf(buf, BUFSIZE - 1, format, ap);
+	va_end(ap);
+	JNIEnv *thisenv = getEnv();
+	jstring string = (*thisenv)->NewStringUTF(thisenv, buf);
+	(*thisenv)->CallStaticObjectMethod(thisenv, CallRFFIHelperClass, RprintfMethodID, string);
+}
+
+void Rvprintf(const char *format, va_list args) {
+	unimplemented("Rvprintf");
+}
+void REvprintf(const char *format, va_list args) {
+	unimplemented("REvprintf");
+}
+
+void R_FlushConsole(void) {
+	// ignored
+}
+
+// Tools package support, not in public API
+
+SEXP R_NewHashedEnv(SEXP parent, SEXP size) {
+	JNIEnv *thisenv = getEnv();
+	int sizeAsInt = Rf_asInteger(size);
+	SEXP result = (*thisenv)->CallStaticObjectMethod(thisenv, RDataFactoryClass, Rf_NewHashedEnvMethodID, parent, NULL, JNI_TRUE, sizeAsInt);
+	return checkRef(thisenv, result);
+}
+
+SEXP Rf_classgets(SEXP x, SEXP y) {
+	unimplemented("Rf_classgets");
+	return NULL;
+}
+
+const char *Rf_translateChar(SEXP x) {
+//	unimplemented("Rf_translateChar");
+	// TODO: proper implementation
+	const char *result = CHAR(x);
+//	printf("translateChar: '%s'\n", result);
+	return result;
+}
+
+const char *Rf_translateChar0(SEXP x) {
+	unimplemented("Rf_translateChar0");
+	return NULL;
+}
+
+const char *Rf_translateCharUTF8(SEXP x) {
+	unimplemented("Rf_translateCharUTF8");
+	return NULL;
+}
+
+const char *Rf_type2char(SEXPTYPE x) {
+	unimplemented("Rf_type2char");
+	return NULL;
+}
+
+SEXP Rf_type2str(SEXPTYPE x) {
+	unimplemented("Rf_type2str");
+	return R_NilValue;
+	return NULL;
+}
+
+SEXP R_FindNamespace(SEXP info) {
+	JNIEnv *thisenv = getEnv();
+	SEXP result = (*thisenv)->CallStaticObjectMethod(thisenv, CallRFFIHelperClass, R_FindNamespaceMethodID, info);
+	return checkRef(thisenv, result);
+}
+
+SEXP Rf_lengthgets(SEXP x, R_len_t y) {
+	return unimplemented("Rf_lengthgets");
+}
+
+SEXP Rf_xlengthgets(SEXP x, R_xlen_t y) {
+	return unimplemented("Rf_xlengthgets");
+
+}
+
+SEXP Rf_namesgets(SEXP x, SEXP y) {
+	return unimplemented("Rf_namesgets");
+}
+
+SEXP GetOption1(SEXP tag)
+{
+	JNIEnv *thisenv = getEnv();
+	SEXP result = (*thisenv)->CallStaticObjectMethod(thisenv, CallRFFIHelperClass, Rf_GetOption1MethodID, tag);
+	return checkRef(thisenv, result);
+}
+
+int GetOptionCutoff(void)
+{
+    int w;
+    w = asInteger(GetOption1(install("deparse.cutoff")));
+    if (w == NA_INTEGER || w <= 0) {
+	warning(_("invalid 'deparse.cutoff', used 60"));
+	w = 60;
+    }
+    return w;
+}
+
+#define R_MIN_WIDTH_OPT		10
+#define R_MAX_WIDTH_OPT		10000
+#define R_MIN_DIGITS_OPT	0
+#define R_MAX_DIGITS_OPT	22
+
+int GetOptionWidth(void)
+{
+    int w;
+    w = asInteger(GetOption1(install("width")));
+    if (w < R_MIN_WIDTH_OPT || w > R_MAX_WIDTH_OPT) {
+	warning(_("invalid printing width, used 80"));
+	return 80;
+    }
+    return w;
+}
+
+int GetOptionDigits(void)
+{
+    int d;
+    d = asInteger(GetOption1(install("digits")));
+    if (d < R_MIN_DIGITS_OPT || d > R_MAX_DIGITS_OPT) {
+	warning(_("invalid printing digits, used 7"));
+	return 7;
+    }
+    return d;
+}
+
+Rboolean Rf_GetOptionDeviceAsk(void)
+{
+    int ask;
+    ask = asLogical(GetOption1(install("device.ask.default")));
+    if(ask == NA_LOGICAL) {
+	warning(_("invalid value for \"device.ask.default\", using FALSE"));
+	return FALSE;
+    }
+    return ask != 0;
+}
+
+void Rf_gsetVar(SEXP symbol, SEXP value, SEXP rho)
+{
+	JNIEnv *thisenv = getEnv();
+	(*thisenv)->CallStaticObjectMethod(thisenv, CallRFFIHelperClass, Rf_gsetVarMethodID, symbol, value, rho);
+}
+
+SEXP TAG(SEXP e) {
+    JNIEnv *thisenv = getEnv();
+    SEXP result = (*thisenv)->CallStaticObjectMethod(thisenv, CallRFFIHelperClass, TAG_MethodID, e);
+    return checkRef(thisenv, result);
+}
+
+SEXP PRINTNAME(SEXP e) {
+    JNIEnv *thisenv = getEnv();
+    SEXP result = (*thisenv)->CallStaticObjectMethod(thisenv, CallRFFIHelperClass, PRINTNAME_MethodID, e);
+    return checkRef(thisenv, result);
+}
+
+SEXP CAR(SEXP e) {
+    JNIEnv *thisenv = getEnv();
+    SEXP result = (*thisenv)->CallStaticObjectMethod(thisenv, CallRFFIHelperClass, CAR_MethodID, e);
+    return checkRef(thisenv, result);
+}
+
+SEXP CDR(SEXP e) {
+    JNIEnv *thisenv = getEnv();
+    SEXP result = (*thisenv)->CallStaticObjectMethod(thisenv, CallRFFIHelperClass, CDR_MethodID, e);
+    return checkRef(thisenv, result);
+}
+
+SEXP CAAR(SEXP e) {
+    unimplemented("CAAR");
+    return NULL;
+}
+
+SEXP CDAR(SEXP e) {
+    unimplemented("CDAR");
+    return NULL;
+}
+
+SEXP CADR(SEXP e) {
+    JNIEnv *thisenv = getEnv();
+    SEXP result = (*thisenv)->CallStaticObjectMethod(thisenv, CallRFFIHelperClass, CADR_MethodID, e);
+    return checkRef(thisenv, result);
+}
+
+SEXP CDDR(SEXP e) {
+    unimplemented("CDDR");
+    return NULL;
+}
+
+SEXP CADDR(SEXP e) {
+    unimplemented("CADDR");
+    return NULL;
+}
+
+SEXP CADDDR(SEXP e) {
+    unimplemented("CADDDR");
+    return NULL;
+}
+
+SEXP CAD4R(SEXP e) {
+    unimplemented("CAD4R");
+    return NULL;
+}
+
+int MISSING(SEXP x){
+    unimplemented("MISSING");
+    return 0;
+}
+
+void SET_MISSING(SEXP x, int v) {
+    unimplemented("SET_MISSING");
+}
+
+void SET_TAG(SEXP x, SEXP y) {
+    unimplemented("SET_TAG");
+}
+
+SEXP SETCAR(SEXP x, SEXP y) {
+    JNIEnv *thisenv = getEnv();
+    SEXP result = (*thisenv)->CallStaticObjectMethod(thisenv, CallRFFIHelperClass, SETCAR_MethodID, x, y);
+    return checkRef(thisenv, result);
+}
+
+SEXP SETCDR(SEXP x, SEXP y) {
+    JNIEnv *thisenv = getEnv();
+    SEXP result = (*thisenv)->CallStaticObjectMethod(thisenv, CallRFFIHelperClass, SETCDR_MethodID, x, y);
+    return checkRef(thisenv, result);
+}
+
+SEXP SETCADR(SEXP x, SEXP y) {
+    unimplemented("SETCADR");
+    return NULL;
+}
+
+SEXP SETCADDR(SEXP x, SEXP y) {
+    unimplemented("SETCADDR");
+    return NULL;
+}
+
+SEXP SETCADDDR(SEXP x, SEXP y) {
+    unimplemented("SETCADDDR");
+    return NULL;
+}
+
+SEXP SETCAD4R(SEXP e, SEXP y) {
+    unimplemented("SETCAD4R");
+    return NULL;
+}
+
+SEXP FORMALS(SEXP x) {
+    return unimplemented("FORMALS");
+}
+
+SEXP BODY(SEXP x) {
+	return unimplemented("BODY");
+}
+
+SEXP CLOENV(SEXP x) {
+	return unimplemented("CLOENV");
+}
+
+int RDEBUG(SEXP x) {
+    return (int) unimplemented("RDEBUG");
+}
+
+int RSTEP(SEXP x) {
+	return (int) unimplemented("RSTEP");
+}
+
+int RTRACE(SEXP x) {
+	return (int) unimplemented("RTRACE");
+}
+
+void SET_RDEBUG(SEXP x, int v) {
+    unimplemented("SET_RDEBUG");
+}
+
+void SET_RSTEP(SEXP x, int v) {
+    unimplemented("SET_RSTEP");
+}
+
+void SET_RTRACE(SEXP x, int v) {
+    unimplemented("SET_RTRACE");
+}
+
+void SET_FORMALS(SEXP x, SEXP v) {
+    unimplemented("SET_FORMALS");
+}
+
+void SET_BODY(SEXP x, SEXP v) {
+    unimplemented("SET_BODY");
+}
+
+void SET_CLOENV(SEXP x, SEXP v) {
+    unimplemented("SET_CLOENV");
+}
+
+SEXP SYMVALUE(SEXP x) {
+	return unimplemented("SYMVALUE");
+}
+
+SEXP INTERNAL(SEXP x) {
+	return unimplemented("INTERNAL");
+}
+
+int DDVAL(SEXP x) {
+	return (int) unimplemented("DDVAL");
+}
+
+void SET_DDVAL(SEXP x, int v) {
+    unimplemented("SET_DDVAL");
+}
+
+void SET_SYMVALUE(SEXP x, SEXP v) {
+    unimplemented("SET_SYMVALUE");
+}
+
+void SET_INTERNAL(SEXP x, SEXP v) {
+    unimplemented("SET_INTERNAL");
+}
+
+
+SEXP FRAME(SEXP x) {
+	return unimplemented("FRAME");
+}
+
+SEXP ENCLOS(SEXP x) {
+	return unimplemented("ENCLOS");
+}
+
+SEXP HASHTAB(SEXP x) {
+	return unimplemented("HASHTAB");
+}
+
+int ENVFLAGS(SEXP x) {
+	return (int) unimplemented("ENVFLAGS");
+}
+
+void SET_ENVFLAGS(SEXP x, int v) {
+	unimplemented("SET_ENVFLAGS");
+}
+
+void SET_FRAME(SEXP x, SEXP v) {
+    unimplemented("SET_FRAME");
+}
+
+void SET_ENCLOS(SEXP x, SEXP v) {
+	unimplemented("SET_ENCLOS");
+}
+
+void SET_HASHTAB(SEXP x, SEXP v) {
+	unimplemented("SET_HASHTAB");
+}
+
+
+SEXP PRCODE(SEXP x) {
+	return unimplemented("PRCODE");
+}
+
+SEXP PRENV(SEXP x) {
+	return unimplemented("PRENV");
+}
+
+SEXP PRVALUE(SEXP x) {
+	return unimplemented("PRVALUE");
+}
+
+int PRSEEN(SEXP x) {
+	return (int) unimplemented("PRSEEN");
+}
+
+void SET_PRSEEN(SEXP x, int v) {
+    unimplemented("SET_PRSEEN");
+}
+
+void SET_PRENV(SEXP x, SEXP v) {
+    unimplemented("SET_PRENV");
+}
+
+void SET_PRVALUE(SEXP x, SEXP v) {
+    unimplemented("SET_PRVALUE");
+}
+
+void SET_PRCODE(SEXP x, SEXP v) {
+    unimplemented("SET_PRCODE");
+}
+
+int LENGTH(SEXP x) {
+    TRACE(TARG1, x);
+    JNIEnv *thisenv = getEnv();
+    return (*thisenv)->CallStaticIntMethod(thisenv, CallRFFIHelperClass, LENGTH_MethodID, x);
+}
+
+int TRUELENGTH(SEXP x){
+    unimplemented("unimplemented");
+    return 0;
+}
+
+
+void SETLENGTH(SEXP x, int v){
+    unimplemented("SETLENGTH");
+}
+
+
+void SET_TRUELENGTH(SEXP x, int v){
+    unimplemented("SET_TRUELENGTH");
+}
+
+
+R_xlen_t XLENGTH(SEXP x){
+    // xlength seems to be used for long vectors (no such thing in FastR at the moment)
+    return LENGTH(x);
+}
+
+
+R_xlen_t XTRUELENGTH(SEXP x){
+	unimplemented("XTRUELENGTH");
+	return 0;
+}
+
+
+int IS_LONG_VEC(SEXP x){
+	unimplemented("IS_LONG_VEC");
+	return 0;
+}
+
+
+int LEVELS(SEXP x){
+	unimplemented("LEVELS");
+	return 0;
+}
+
+
+int SETLEVELS(SEXP x, int v){
+	unimplemented("SETLEVELS");
+	return 0;
+}
+
+int *LOGICAL(SEXP x){
+	TRACE(TARG1, x);
+	JNIEnv *thisenv = getEnv();
+	jint *data = (jint *) findCopiedObject(thisenv, x);
+	if (data == NULL) {
+	    jintArray intArray = (*thisenv)->CallStaticObjectMethod(thisenv, CallRFFIHelperClass, LOGICAL_MethodID, x);
+	    int len = (*thisenv)->GetArrayLength(thisenv, intArray);
+	    data = (*thisenv)->GetIntArrayElements(thisenv, intArray, NULL);
+	    addCopiedObject(thisenv, x, LGLSXP, intArray, data);
+	}
+	return data;
+}
+
+int *INTEGER(SEXP x){
+	TRACE(TARG1, x);
+	JNIEnv *thisenv = getEnv();
+	jint *data = (jint *) findCopiedObject(thisenv, x);
+	if (data == NULL) {
+	    jintArray intArray = (*thisenv)->CallStaticObjectMethod(thisenv, CallRFFIHelperClass, INTEGER_MethodID, x);
+	    int len = (*thisenv)->GetArrayLength(thisenv, intArray);
+	    data = (*thisenv)->GetIntArrayElements(thisenv, intArray, NULL);
+	    addCopiedObject(thisenv, x, INTSXP, intArray, data);
+	}
+	return data;
+}
+
+
+Rbyte *RAW(SEXP x){
+	JNIEnv *thisenv = getEnv();
+	jbyte *data = (jbyte *) findCopiedObject(thisenv, x);
+	if (data == NULL) {
+	    jbyteArray byteArray = (*thisenv)->CallStaticObjectMethod(thisenv, CallRFFIHelperClass, RAW_MethodID, x);
+	    int len = (*thisenv)->GetArrayLength(thisenv, byteArray);
+	    data = (*thisenv)->GetByteArrayElements(thisenv, byteArray, NULL);
+        addCopiedObject(thisenv, x, RAWSXP, byteArray, data);
+    }
+	return (Rbyte*) data;
+}
+
+
+double *REAL(SEXP x){
+    JNIEnv *thisenv = getEnv();
+    jdouble *data = (jdouble *) findCopiedObject(thisenv, x);
+    if (data == NULL) {
+	jdoubleArray doubleArray = (*thisenv)->CallStaticObjectMethod(thisenv, CallRFFIHelperClass, REAL_MethodID, x);
+	int len = (*thisenv)->GetArrayLength(thisenv, doubleArray);
+	data = (*thisenv)->GetDoubleArrayElements(thisenv, doubleArray, NULL);
+	addCopiedObject(thisenv, x, REALSXP, doubleArray, data);
+    }
+    return data;
+}
+
+
+Rcomplex *COMPLEX(SEXP x){
+	unimplemented("COMPLEX");
+	return NULL;
+}
+
+
+SEXP STRING_ELT(SEXP x, R_xlen_t i){
+	TRACE(TARG2d, x, i);
+	JNIEnv *thisenv = getEnv();
+    SEXP result = (*thisenv)->CallStaticObjectMethod(thisenv, CallRFFIHelperClass, STRING_ELT_MethodID, x, i);
+    return checkRef(thisenv, result);
+}
+
+
+SEXP VECTOR_ELT(SEXP x, R_xlen_t i){
+	JNIEnv *thisenv = getEnv();
+    SEXP result = (*thisenv)->CallStaticObjectMethod(thisenv, CallRFFIHelperClass, VECTOR_ELT_MethodID, x, i);
+    return checkRef(thisenv, result);
+}
+
+void SET_STRING_ELT(SEXP x, R_xlen_t i, SEXP v){
+	JNIEnv *thisenv = getEnv();
+	(*thisenv)->CallStaticVoidMethod(thisenv, CallRFFIHelperClass, SET_STRING_ELT_MethodID, x, i, v);
+}
+
+
+SEXP SET_VECTOR_ELT(SEXP x, R_xlen_t i, SEXP v){
+	JNIEnv *thisenv = getEnv();
+	(*thisenv)->CallStaticVoidMethod(thisenv, CallRFFIHelperClass, SET_VECTOR_ELT_MethodID, x, i, v);
+	return v;
+}
+
+
+SEXP *STRING_PTR(SEXP x){
+	unimplemented("STRING_PTR");
+	return NULL;
+}
+
+
+SEXP *VECTOR_PTR(SEXP x){
+	unimplemented("VECTOR_PTR");
+	return NULL;
+}
+
+SEXP Rf_asChar(SEXP x){
+	TRACE(TARG1, x);
+	JNIEnv *thisenv = getEnv();
+	SEXP result = (*thisenv)->CallStaticObjectMethod(thisenv, CallRFFIHelperClass, Rf_asCharMethodID, x);
+	return checkRef(thisenv, result);
+}
+
+SEXP Rf_PairToVectorList(SEXP x){
+	JNIEnv *thisenv = getEnv();
+	SEXP result = (*thisenv)->CallStaticObjectMethod(thisenv, CallRFFIHelperClass, Rf_PairToVectorListMethodID, x);
+	return checkRef(thisenv, result);
+}
+
+SEXP Rf_VectorToPairList(SEXP x){
+	unimplemented("Rf_coerceVector");
+	return NULL;
+}
+
+SEXP Rf_asCharacterFactor(SEXP x){
+	unimplemented("Rf_VectorToPairList");
+	return NULL;
+}
+
+int Rf_asLogical(SEXP x){
+	TRACE(TARG1, x);
+	JNIEnv *thisenv = getEnv();
+	return (*thisenv)->CallStaticIntMethod(thisenv, CallRFFIHelperClass, Rf_asLogicalMethodID, x);
+}
+
+int Rf_asInteger(SEXP x) {
+	TRACE(TARG1, x);
+	JNIEnv *thisenv = getEnv();
+	return (*thisenv)->CallStaticIntMethod(thisenv, CallRFFIHelperClass, Rf_asIntegerMethodID, x);
+}
+
+//double Rf_asReal(SEXP x) {
+//	TRACE(TARG1, x);
+//	JNIEnv *thisenv = getEnv();
+//	return (*thisenv)->CallStaticDoubleMethod(thisenv, CallRFFIHelperClass, Rf_asRealMethodID, x);
+//}
+
+Rcomplex Rf_asComplex(SEXP x){
+	unimplemented("Rf_asLogical");
+	Rcomplex c; return c;
+}
+
+int TYPEOF(SEXP x) {
+    JNIEnv *thisenv = getEnv();
+    return (*thisenv)->CallStaticIntMethod(thisenv, SEXPTYPEClass, gnuRCodeForObjectMethodID, x);
+}
+
+SEXP ATTRIB(SEXP x){
+    unimplemented("ATTRIB");
+    return NULL;
+}
+
+int OBJECT(SEXP x){
+    unimplemented("OBJECT");
+    return 0;
+}
+
+int MARK(SEXP x){
+    unimplemented("MARK");
+    return 0;
+}
+
+int NAMED(SEXP x){
+    JNIEnv *thisenv = getEnv();
+    return (*thisenv)->CallStaticIntMethod(thisenv, CallRFFIHelperClass, NAMED_MethodID, x);
+}
+
+int REFCNT(SEXP x){
+    unimplemented("REFCNT");
+    return 0;
+}
+
+void SET_OBJECT(SEXP x, int v){
+    unimplemented("SET_OBJECT");
+}
+
+void SET_TYPEOF(SEXP x, int v){
+    unimplemented("SET_TYPEOF");
+}
+
+void SET_NAMED(SEXP x, int v){
+    unimplemented("SET_NAMED");
+}
+
+void SET_ATTRIB(SEXP x, SEXP v){
+    unimplemented("SET_ATTRIB");
+}
+
+void DUPLICATE_ATTRIB(SEXP to, SEXP from){
+    JNIEnv *thisenv = getEnv();
+    (*thisenv)->CallStaticVoidMethod(thisenv, CallRFFIHelperClass, DUPLICATE_ATTRIB_MethodID, to, from);
+}
+
+char *dgettext(const char *domainname, const char *msgid) {
+	printf("dgettext: '%s'\n", msgid);
+	return (char*) msgid;
+}
+
+const char *R_CHAR(SEXP string) {
+	TRACE("%s(%p)", string);
+	// This is nasty:
+	// 1. the resulting character array has to be copied and zero-terminated.
+	// 2. It causes an (inevitable?) memory leak
+	JNIEnv *thisenv = getEnv();
+#if VALIDATE_REFS
+	validateRef(thisenv, string, "R_CHAR");
+#endif
+	jsize len = (*thisenv)->GetStringUTFLength(thisenv, string);
+	const char *stringChars = (*thisenv)->GetStringUTFChars(thisenv, string, NULL);
+	char *copyChars = malloc(len + 1);
+	memcpy(copyChars, stringChars, len);
+	copyChars[len] = 0;
+	return copyChars;
+}
+
+void R_qsort_I  (double *v, int *II, int i, int j) {
+	unimplemented("R_qsort_I");
+}
+
+void R_qsort_int_I(int *iv, int *II, int i, int j) {
+	unimplemented("R_qsort_int_I");
+}
+
+void R_CheckUserInterrupt() {
+// TODO (we don't even do this in the Java code)
+}
+
+R_len_t R_BadLongVector(SEXP x, const char *y, int z) {
+	return (R_len_t) unimplemented("R_BadLongVector");
+}
+
+int IS_S4_OBJECT(SEXP x) {
+	JNIEnv *env = getEnv();
+	return 	(*env)->CallStaticIntMethod(env, CallRFFIHelperClass, iS4ObjectMethodID, x);
+}
+
+void SET_S4_OBJECT(SEXP x) {
+	unimplemented("SET_S4_OBJECT");
+}
+void UNSET_S4_OBJECT(SEXP x) {
+	unimplemented("UNSET_S4_OBJECT");
+}
+
+Rboolean R_ToplevelExec(void (*fun)(void *), void *data) {
+	return (Rboolean) unimplemented("R_ToplevelExec");
+}
+
+SEXP R_ExecWithCleanup(SEXP (*fun)(void *), void *data,
+		       void (*cleanfun)(void *), void *cleandata) {
+	return unimplemented("R_ExecWithCleanup");
+}
+
+SEXP R_tryEval(SEXP x, SEXP y, int *z) {
+	return unimplemented("R_tryEval");
+}
+
+SEXP R_tryEvalSilent(SEXP x, SEXP y, int *z) {
+	return unimplemented("R_tryEvalSilent");
+}
+
+size_t Riconv (void *cd, const char **inbuf, size_t *inbytesleft,
+	       char **outbuf, size_t *outbytesleft) {
+	return (size_t) unimplemented("Riconv");
+}
+
+int Riconv_close (void *cd) {
+	return (int) unimplemented("Riconv_close");
+	return 0;
+}
+
+void * Riconv_open (const char* tocode, const char* fromcode) {
+	return unimplemented("Riconv_open");
+}
+
+double R_atof(const char *str) {
+	unimplemented("R_atof");
+	return 0;
+}
+
+double R_strtod(const char *c, char **end) {
+	unimplemented("R_strtod");
+	return 0;
+}
+
+const char *reEnc(const char *x, cetype_t ce_in, cetype_t ce_out, int subst) {
+    // TODO: proper implementation of reEnc
+    return x;
+}
+
+SEXP R_PromiseExpr(SEXP x) {
+	return unimplemented("R_PromiseExpr");
+}
+
+SEXP R_ClosureExpr(SEXP x) {
+	return unimplemented("R_ClosureExpr");
+}
+
+SEXP R_MakeExternalPtr(void *p, SEXP tag, SEXP prot) {
+	JNIEnv *thisenv = getEnv();
+	SEXP result =  (*thisenv)->CallStaticObjectMethod(thisenv, RDataFactoryClass, createExternalPtrMethodID, (jlong) p, tag, prot);
+    return checkRef(thisenv, result);
+}
+
+void *R_ExternalPtrAddr(SEXP s) {
+	JNIEnv *thisenv = getEnv();
+	return (void *) (*thisenv)->CallLongMethod(thisenv, s, externalPtrGetAddrMethodID);
+}
+
+SEXP R_ExternalPtrTag(SEXP s) {
+	JNIEnv *thisenv = getEnv();
+	SEXP result =  (*thisenv)->CallObjectMethod(thisenv, s, externalPtrGetTagMethodID);
+    return checkRef(thisenv, result);
+}
+
+SEXP R_ExternalPtrProt(SEXP s) {
+	JNIEnv *thisenv = getEnv();
+	SEXP result =  (*thisenv)->CallObjectMethod(thisenv, s, externalPtrGetProtMethodID);
+    return checkRef(thisenv, result);
+}
+
+void R_SetExternalPtrAddr(SEXP s, void *p) {
+	JNIEnv *thisenv = getEnv();
+	(*thisenv)->CallLongMethod(thisenv, s, externalPtrSetAddrMethodID, (jlong) p);
+}
+
+void R_SetExternalPtrTag(SEXP s, SEXP tag) {
+	JNIEnv *thisenv = getEnv();
+	(*thisenv)->CallObjectMethod(thisenv, s, externalPtrSetTagMethodID, tag);
+}
+
+void R_SetExternalPtrProt(SEXP s, SEXP p) {
+	JNIEnv *thisenv = getEnv();
+	(*thisenv)->CallObjectMethod(thisenv, s, externalPtrSetProtMethodID, p);
+}
+
+void R_ClearExternalPtr(SEXP s) {
+	R_SetExternalPtrAddr(s, NULL);
+}
+
+void R_RegisterFinalizer(SEXP s, SEXP fun) {
+	// TODO implement, but not fail for now
+}
+void R_RegisterCFinalizer(SEXP s, R_CFinalizer_t fun) {
+	// TODO implement, but not fail for now
+}
+
+void R_RegisterFinalizerEx(SEXP s, SEXP fun, Rboolean onexit) {
+	// TODO implement, but not fail for now
+
+}
+
+void R_RegisterCFinalizerEx(SEXP s, R_CFinalizer_t fun, Rboolean onexit) {
+	// TODO implement, but not fail for now
+}
+
+void R_RunPendingFinalizers(void) {
+	// TODO implement, but not fail for now
+}
+
+
diff --git a/com.oracle.truffle.r.native/fficall/jni/src/rmathc.c b/com.oracle.truffle.r.native/fficall/jni/src/Rmath.c
similarity index 100%
rename from com.oracle.truffle.r.native/fficall/jni/src/rmathc.c
rename to com.oracle.truffle.r.native/fficall/jni/src/Rmath.c
diff --git a/com.oracle.truffle.r.native/fficall/jni/src/errors.c b/com.oracle.truffle.r.native/fficall/jni/src/Utils.c
similarity index 100%
rename from com.oracle.truffle.r.native/fficall/jni/src/errors.c
rename to com.oracle.truffle.r.native/fficall/jni/src/Utils.c
diff --git a/com.oracle.truffle.r.native/fficall/jni/src/access_functions.c b/com.oracle.truffle.r.native/fficall/jni/src/access_functions.c
deleted file mode 100644
index 7238f40e0e25c8f84af4254467062969c9908ab5..0000000000000000000000000000000000000000
--- a/com.oracle.truffle.r.native/fficall/jni/src/access_functions.c
+++ /dev/null
@@ -1,287 +0,0 @@
-/*
- * Copyright (c) 2015, 2015, 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.
- */
-
-#include "rffiutils.h"
-
-static jmethodID CADR_MethodID;
-static jmethodID TAG_MethodID;
-static jmethodID PRINTNAME_MethodID;
-static jmethodID CAR_MethodID;
-static jmethodID CDR_MethodID;
-static jmethodID SETCAR_MethodID;
-static jmethodID SETCDR_MethodID;
-
-void init_listaccess(JNIEnv *env) {
-    CADR_MethodID = checkGetMethodID(env, CallRFFIHelperClass, "CADR", "(Ljava/lang/Object;)Ljava/lang/Object;", 1);
-    TAG_MethodID = checkGetMethodID(env, CallRFFIHelperClass, "TAG", "(Ljava/lang/Object;)Ljava/lang/Object;", 1);
-    PRINTNAME_MethodID = checkGetMethodID(env, CallRFFIHelperClass, "PRINTNAME", "(Ljava/lang/Object;)Ljava/lang/Object;", 1);
-    CAR_MethodID = checkGetMethodID(env, CallRFFIHelperClass, "CAR", "(Ljava/lang/Object;)Ljava/lang/Object;", 1);
-    CDR_MethodID = checkGetMethodID(env, CallRFFIHelperClass, "CDR", "(Ljava/lang/Object;)Ljava/lang/Object;", 1);
-    SETCAR_MethodID = checkGetMethodID(env, CallRFFIHelperClass, "SETCAR", "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;", 1);
-    SETCDR_MethodID = checkGetMethodID(env, CallRFFIHelperClass, "SETCDR", "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;", 1);
-}
-
-SEXP TAG(SEXP e) {
-    JNIEnv *thisenv = getEnv();
-    SEXP result = (*thisenv)->CallStaticObjectMethod(thisenv, CallRFFIHelperClass, TAG_MethodID, e);
-    return checkRef(thisenv, result);
-}
-
-SEXP PRINTNAME(SEXP e) {
-    JNIEnv *thisenv = getEnv();
-    SEXP result = (*thisenv)->CallStaticObjectMethod(thisenv, CallRFFIHelperClass, PRINTNAME_MethodID, e);
-    return checkRef(thisenv, result);
-}
-
-SEXP CAR(SEXP e) {
-    JNIEnv *thisenv = getEnv();
-    SEXP result = (*thisenv)->CallStaticObjectMethod(thisenv, CallRFFIHelperClass, CAR_MethodID, e);
-    return checkRef(thisenv, result);
-}
-
-SEXP CDR(SEXP e) {
-    JNIEnv *thisenv = getEnv();
-    SEXP result = (*thisenv)->CallStaticObjectMethod(thisenv, CallRFFIHelperClass, CDR_MethodID, e);
-    return checkRef(thisenv, result);
-}
-
-SEXP CAAR(SEXP e) {
-    unimplemented("CAAR");
-    return NULL;
-}
-
-SEXP CDAR(SEXP e) {
-    unimplemented("CDAR");
-    return NULL;
-}
-
-SEXP CADR(SEXP e) {
-    JNIEnv *thisenv = getEnv();
-    SEXP result = (*thisenv)->CallStaticObjectMethod(thisenv, CallRFFIHelperClass, CADR_MethodID, e);
-    return checkRef(thisenv, result);
-}
-
-SEXP CDDR(SEXP e) {
-    unimplemented("CDDR");
-    return NULL;
-}
-
-SEXP CADDR(SEXP e) {
-    unimplemented("CADDR");
-    return NULL;
-}
-
-SEXP CADDDR(SEXP e) {
-    unimplemented("CADDDR");
-    return NULL;
-}
-
-SEXP CAD4R(SEXP e) {
-    unimplemented("CAD4R");
-    return NULL;
-}
-
-int MISSING(SEXP x){
-    unimplemented("MISSING");
-    return 0;
-}
-
-void SET_MISSING(SEXP x, int v) {
-    unimplemented("SET_MISSING");
-}
-
-void SET_TAG(SEXP x, SEXP y) {
-    unimplemented("SET_TAG");
-}
-
-SEXP SETCAR(SEXP x, SEXP y) {
-    JNIEnv *thisenv = getEnv();
-    SEXP result = (*thisenv)->CallStaticObjectMethod(thisenv, CallRFFIHelperClass, SETCAR_MethodID, x, y);
-    return checkRef(thisenv, result);
-}
-
-SEXP SETCDR(SEXP x, SEXP y) {
-    JNIEnv *thisenv = getEnv();
-    SEXP result = (*thisenv)->CallStaticObjectMethod(thisenv, CallRFFIHelperClass, SETCDR_MethodID, x, y);
-    return checkRef(thisenv, result);
-}
-
-SEXP SETCADR(SEXP x, SEXP y) {
-    unimplemented("SETCADR");
-    return NULL;
-}
-
-SEXP SETCADDR(SEXP x, SEXP y) {
-    unimplemented("SETCADDR");
-    return NULL;
-}
-
-SEXP SETCADDDR(SEXP x, SEXP y) {
-    unimplemented("SETCADDDR");
-    return NULL;
-}
-
-SEXP SETCAD4R(SEXP e, SEXP y) {
-    unimplemented("SETCAD4R");
-    return NULL;
-}
-
-SEXP FORMALS(SEXP x) {
-    return unimplemented("FORMALS");
-}
-
-SEXP BODY(SEXP x) {
-	return unimplemented("BODY");
-}
-
-SEXP CLOENV(SEXP x) {
-	return unimplemented("CLOENV");
-}
-
-int RDEBUG(SEXP x) {
-    return (int) unimplemented("RDEBUG");
-}
-
-int RSTEP(SEXP x) {
-	return (int) unimplemented("RSTEP");
-}
-
-int RTRACE(SEXP x) {
-	return (int) unimplemented("RTRACE");
-}
-
-void SET_RDEBUG(SEXP x, int v) {
-    unimplemented("SET_RDEBUG");
-}
-
-void SET_RSTEP(SEXP x, int v) {
-    unimplemented("SET_RSTEP");
-}
-
-void SET_RTRACE(SEXP x, int v) {
-    unimplemented("SET_RTRACE");
-}
-
-void SET_FORMALS(SEXP x, SEXP v) {
-    unimplemented("SET_FORMALS");
-}
-
-void SET_BODY(SEXP x, SEXP v) {
-    unimplemented("SET_BODY");
-}
-
-void SET_CLOENV(SEXP x, SEXP v) {
-    unimplemented("SET_CLOENV");
-}
-
-SEXP SYMVALUE(SEXP x) {
-	return unimplemented("SYMVALUE");
-}
-
-SEXP INTERNAL(SEXP x) {
-	return unimplemented("INTERNAL");
-}
-
-int DDVAL(SEXP x) {
-	return (int) unimplemented("DDVAL");
-}
-
-void SET_DDVAL(SEXP x, int v) {
-    unimplemented("SET_DDVAL");
-}
-
-void SET_SYMVALUE(SEXP x, SEXP v) {
-    unimplemented("SET_SYMVALUE");
-}
-
-void SET_INTERNAL(SEXP x, SEXP v) {
-    unimplemented("SET_INTERNAL");
-}
-
-
-SEXP FRAME(SEXP x) {
-	return unimplemented("FRAME");
-}
-
-SEXP ENCLOS(SEXP x) {
-	return unimplemented("ENCLOS");
-}
-
-SEXP HASHTAB(SEXP x) {
-	return unimplemented("HASHTAB");
-}
-
-int ENVFLAGS(SEXP x) {
-	return (int) unimplemented("ENVFLAGS");
-}
-
-void SET_ENVFLAGS(SEXP x, int v) {
-	unimplemented("SET_ENVFLAGS");
-}
-
-void SET_FRAME(SEXP x, SEXP v) {
-    unimplemented("SET_FRAME");
-}
-
-void SET_ENCLOS(SEXP x, SEXP v) {
-	unimplemented("SET_ENCLOS");
-}
-
-void SET_HASHTAB(SEXP x, SEXP v) {
-	unimplemented("SET_HASHTAB");
-}
-
-
-SEXP PRCODE(SEXP x) {
-	return unimplemented("PRCODE");
-}
-
-SEXP PRENV(SEXP x) {
-	return unimplemented("PRENV");
-}
-
-SEXP PRVALUE(SEXP x) {
-	return unimplemented("PRVALUE");
-}
-
-int PRSEEN(SEXP x) {
-	return (int) unimplemented("PRSEEN");
-}
-
-void SET_PRSEEN(SEXP x, int v) {
-    unimplemented("SET_PRSEEN");
-}
-
-void SET_PRENV(SEXP x, SEXP v) {
-    unimplemented("SET_PRENV");
-}
-
-void SET_PRVALUE(SEXP x, SEXP v) {
-    unimplemented("SET_PRVALUE");
-}
-
-void SET_PRCODE(SEXP x, SEXP v) {
-    unimplemented("SET_PRCODE");
-}
-
-
diff --git a/com.oracle.truffle.r.native/fficall/jni/src/attrib.c b/com.oracle.truffle.r.native/fficall/jni/src/attrib.c
deleted file mode 100644
index 2d357d13a7951c4276bcce12f48d75b180748098..0000000000000000000000000000000000000000
--- a/com.oracle.truffle.r.native/fficall/jni/src/attrib.c
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Copyright (c) 2015, 2015, 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.
- */
-#include "rffiutils.h"
-
-static jclass SEXPTYPEClass;
-static jmethodID gnuRCodeForObjectMethodID;
-static jmethodID NAMED_MethodID;
-static jmethodID DUPLICATE_ATTRIB_MethodID;
-
-void init_attrib(JNIEnv *env) {
-	SEXPTYPEClass = checkFindClass(env, "com/oracle/truffle/r/runtime/gnur/SEXPTYPE");
-	gnuRCodeForObjectMethodID = checkGetMethodID(env, SEXPTYPEClass, "gnuRCodeForObject", "(Ljava/lang/Object;)I", 1);
-	NAMED_MethodID = checkGetMethodID(env, CallRFFIHelperClass, "NAMED", "(Ljava/lang/Object;)I", 1);
-	DUPLICATE_ATTRIB_MethodID = checkGetMethodID(env, CallRFFIHelperClass, "DUPLICATE_ATTRIB", "(Ljava/lang/Object;Ljava/lang/Object;)V", 1);
-}
-
-int TYPEOF(SEXP x) {
-    JNIEnv *thisenv = getEnv();
-    return (*thisenv)->CallStaticIntMethod(thisenv, SEXPTYPEClass, gnuRCodeForObjectMethodID, x);
-}
-
-SEXP ATTRIB(SEXP x){
-    unimplemented("ATTRIB");
-    return NULL;
-}
-
-int OBJECT(SEXP x){
-    unimplemented("OBJECT");
-    return 0;
-}
-
-int MARK(SEXP x){
-    unimplemented("MARK");
-    return 0;
-}
-
-int NAMED(SEXP x){
-    JNIEnv *thisenv = getEnv();
-    return (*thisenv)->CallStaticIntMethod(thisenv, CallRFFIHelperClass, NAMED_MethodID, x);
-}
-
-int REFCNT(SEXP x){
-    unimplemented("REFCNT");
-    return 0;
-}
-
-void SET_OBJECT(SEXP x, int v){
-    unimplemented("SET_OBJECT");
-}
-
-void SET_TYPEOF(SEXP x, int v){
-    unimplemented("SET_TYPEOF");
-}
-
-void SET_NAMED(SEXP x, int v){
-    unimplemented("SET_NAMED");
-}
-
-void SET_ATTRIB(SEXP x, SEXP v){
-    unimplemented("SET_ATTRIB");
-}
-
-void DUPLICATE_ATTRIB(SEXP to, SEXP from){
-    JNIEnv *thisenv = getEnv();
-    (*thisenv)->CallStaticVoidMethod(thisenv, CallRFFIHelperClass, DUPLICATE_ATTRIB_MethodID, to, from);
-}
-
diff --git a/com.oracle.truffle.r.native/fficall/jni/src/typecoerce.c b/com.oracle.truffle.r.native/fficall/jni/src/coerce.c
similarity index 84%
rename from com.oracle.truffle.r.native/fficall/jni/src/typecoerce.c
rename to com.oracle.truffle.r.native/fficall/jni/src/coerce.c
index 6271687d2a2b7f702f1d53c38a263564e397042c..f8d675e7b9e3f017fdc4bfa9a74b85f1c7ba84b7 100644
--- a/com.oracle.truffle.r.native/fficall/jni/src/typecoerce.c
+++ b/com.oracle.truffle.r.native/fficall/jni/src/coerce.c
@@ -25,67 +25,6 @@
 
 #define _(Source) (Source)
 
-static jmethodID Rf_asIntegerMethodID;
-//static jmethodID Rf_asRealMethodID;
-static jmethodID Rf_asCharMethodID;
-static jmethodID Rf_asLogicalMethodID;
-static jmethodID Rf_PairToVectorListMethodID;
-
-void init_typecoerce(JNIEnv *env) {
-	Rf_asIntegerMethodID = checkGetMethodID(env, CallRFFIHelperClass, "Rf_asInteger", "(Ljava/lang/Object;)I", 1);
-//	Rf_asRealMethodID = checkGetMethodID(env, CallRFFIHelperClass, "Rf_asReal", "(Ljava/lang/Object;)D", 1);
-	Rf_asCharMethodID = checkGetMethodID(env, CallRFFIHelperClass, "Rf_asChar", "(Ljava/lang/Object;)Ljava/lang/String;", 1);
-	Rf_asLogicalMethodID = checkGetMethodID(env, CallRFFIHelperClass, "Rf_asLogical", "(Ljava/lang/Object;)I", 1);
-	Rf_PairToVectorListMethodID = checkGetMethodID(env, CallRFFIHelperClass, "Rf_PairToVectorList", "(Ljava/lang/Object;)Ljava/lang/Object;", 1);
-}
-
-SEXP Rf_asChar(SEXP x){
-	TRACE(TARG1, x);
-	JNIEnv *thisenv = getEnv();
-	SEXP result = (*thisenv)->CallStaticObjectMethod(thisenv, CallRFFIHelperClass, Rf_asCharMethodID, x);
-	return checkRef(thisenv, result);
-}
-
-SEXP Rf_PairToVectorList(SEXP x){
-	JNIEnv *thisenv = getEnv();
-	SEXP result = (*thisenv)->CallStaticObjectMethod(thisenv, CallRFFIHelperClass, Rf_PairToVectorListMethodID, x);
-	return checkRef(thisenv, result);
-}
-
-SEXP Rf_VectorToPairList(SEXP x){
-	unimplemented("Rf_coerceVector");
-	return NULL;
-}
-
-SEXP Rf_asCharacterFactor(SEXP x){
-	unimplemented("Rf_VectorToPairList");
-	return NULL;
-}
-
-int Rf_asLogical(SEXP x){
-	TRACE(TARG1, x);
-	JNIEnv *thisenv = getEnv();
-	return (*thisenv)->CallStaticIntMethod(thisenv, CallRFFIHelperClass, Rf_asLogicalMethodID, x);
-}
-
-int Rf_asInteger(SEXP x) {
-	TRACE(TARG1, x);
-	JNIEnv *thisenv = getEnv();
-	return (*thisenv)->CallStaticIntMethod(thisenv, CallRFFIHelperClass, Rf_asIntegerMethodID, x);
-}
-
-//double Rf_asReal(SEXP x) {
-//	TRACE(TARG1, x);
-//	JNIEnv *thisenv = getEnv();
-//	return (*thisenv)->CallStaticDoubleMethod(thisenv, CallRFFIHelperClass, Rf_asRealMethodID, x);
-//}
-
-Rcomplex Rf_asComplex(SEXP x){
-	unimplemented("Rf_asLogical");
-	Rcomplex c; return c;
-}
-
-
 // selected functions from coerce.c:
 
 /*
diff --git a/com.oracle.truffle.r.native/fficall/jni/src/externalptr.c b/com.oracle.truffle.r.native/fficall/jni/src/externalptr.c
deleted file mode 100644
index 8ab12aa5826a615aab60f2987f2e25dcb7cb9d1d..0000000000000000000000000000000000000000
--- a/com.oracle.truffle.r.native/fficall/jni/src/externalptr.c
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Copyright (c) 2015, 2015, 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.
- */
-#include "rffiutils.h"
-
-static jclass RExternalPtrClass;
-static jmethodID createExternalPtrMethodID;
-static jmethodID externalPtrGetAddrMethodID;
-static jmethodID externalPtrGetTagMethodID;
-static jmethodID externalPtrGetProtMethodID;
-static jmethodID externalPtrSetAddrMethodID;
-static jmethodID externalPtrSetTagMethodID;
-static jmethodID externalPtrSetProtMethodID;
-
-void init_externalptr(JNIEnv *env) {
-	RExternalPtrClass = checkFindClass(env, "com/oracle/truffle/r/runtime/data/RExternalPtr");
-	createExternalPtrMethodID = checkGetMethodID(env, RDataFactoryClass, "createExternalPtr", "(JLjava/lang/Object;Ljava/lang/Object;)Lcom/oracle/truffle/r/runtime/data/RExternalPtr;", 1);
-	externalPtrGetAddrMethodID = checkGetMethodID(env, RExternalPtrClass, "getAddr", "()J", 0);
-	externalPtrGetTagMethodID = checkGetMethodID(env, RExternalPtrClass, "getTag", "()Ljava/lang/Object;", 0);
-	externalPtrGetProtMethodID = checkGetMethodID(env, RExternalPtrClass, "getProt", "()Ljava/lang/Object;", 0);
-	externalPtrSetAddrMethodID = checkGetMethodID(env, RExternalPtrClass, "setAddr", "(J)V", 0);
-	externalPtrSetTagMethodID = checkGetMethodID(env, RExternalPtrClass, "setTag", "(Ljava/lang/Object;)V", 0);
-	externalPtrSetProtMethodID = checkGetMethodID(env, RExternalPtrClass, "setProt", "(Ljava/lang/Object;)V", 0);
-
-}
-
-SEXP R_MakeExternalPtr(void *p, SEXP tag, SEXP prot) {
-	JNIEnv *thisenv = getEnv();
-	SEXP result =  (*thisenv)->CallStaticObjectMethod(thisenv, RDataFactoryClass, createExternalPtrMethodID, (jlong) p, tag, prot);
-    return checkRef(thisenv, result);
-}
-
-void *R_ExternalPtrAddr(SEXP s) {
-	JNIEnv *thisenv = getEnv();
-	return (void *) (*thisenv)->CallLongMethod(thisenv, s, externalPtrGetAddrMethodID);
-}
-
-SEXP R_ExternalPtrTag(SEXP s) {
-	JNIEnv *thisenv = getEnv();
-	SEXP result =  (*thisenv)->CallObjectMethod(thisenv, s, externalPtrGetTagMethodID);
-    return checkRef(thisenv, result);
-}
-
-SEXP R_ExternalPtrProt(SEXP s) {
-	JNIEnv *thisenv = getEnv();
-	SEXP result =  (*thisenv)->CallObjectMethod(thisenv, s, externalPtrGetProtMethodID);
-    return checkRef(thisenv, result);
-}
-
-void R_SetExternalPtrAddr(SEXP s, void *p) {
-	JNIEnv *thisenv = getEnv();
-	(*thisenv)->CallLongMethod(thisenv, s, externalPtrSetAddrMethodID, (jlong) p);
-}
-
-void R_SetExternalPtrTag(SEXP s, SEXP tag) {
-	JNIEnv *thisenv = getEnv();
-	(*thisenv)->CallObjectMethod(thisenv, s, externalPtrSetTagMethodID, tag);
-}
-
-void R_SetExternalPtrProt(SEXP s, SEXP p) {
-	JNIEnv *thisenv = getEnv();
-	(*thisenv)->CallObjectMethod(thisenv, s, externalPtrSetProtMethodID, p);
-}
-
-void R_ClearExternalPtr(SEXP s) {
-	R_SetExternalPtrAddr(s, NULL);
-}
-
diff --git a/com.oracle.truffle.r.native/fficall/jni/src/misc.c b/com.oracle.truffle.r.native/fficall/jni/src/misc.c
deleted file mode 100644
index 27452f47f7f0b888468c449a1febacbacb6c47d1..0000000000000000000000000000000000000000
--- a/com.oracle.truffle.r.native/fficall/jni/src/misc.c
+++ /dev/null
@@ -1,158 +0,0 @@
-/*
- * Copyright (c) 2015, 2015, 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.
- */
-#include "rffiutils.h"
-#include <stdlib.h>
-#include <string.h>
-
-jmethodID iS4ObjectMethodID;
-
-void init_misc(JNIEnv *env) {
-	iS4ObjectMethodID = checkGetMethodID(env, CallRFFIHelperClass, "isS4Object", "(Ljava/lang/Object;)I", 1);
-}
-
-char *dgettext(const char *domainname, const char *msgid) {
-	printf("dgettext: '%s'\n", msgid);
-	return (char*) msgid;
-}
-
-const char *R_CHAR(SEXP string) {
-	TRACE("%s(%p)", string);
-	// This is nasty:
-	// 1. the resulting character array has to be copied and zero-terminated.
-	// 2. It causes an (inevitable?) memory leak
-	JNIEnv *thisenv = getEnv();
-#if VALIDATE_REFS
-	validateRef(thisenv, string, "R_CHAR");
-#endif
-	jsize len = (*thisenv)->GetStringUTFLength(thisenv, string);
-	const char *stringChars = (*thisenv)->GetStringUTFChars(thisenv, string, NULL);
-	char *copyChars = malloc(len + 1);
-	memcpy(copyChars, stringChars, len);
-	copyChars[len] = 0;
-	return copyChars;
-}
-
-void R_qsort_I  (double *v, int *II, int i, int j) {
-	unimplemented("R_qsort_I");
-}
-
-void R_qsort_int_I(int *iv, int *II, int i, int j) {
-	unimplemented("R_qsort_int_I");
-}
-
-void R_CheckUserInterrupt() {
-// TODO (we don't even do this in the Java code)
-}
-
-R_len_t R_BadLongVector(SEXP x, const char *y, int z) {
-	return (R_len_t) unimplemented("R_BadLongVector");
-}
-
-int IS_S4_OBJECT(SEXP x) {
-	JNIEnv *env = getEnv();
-	return 	(*env)->CallStaticIntMethod(env, CallRFFIHelperClass, iS4ObjectMethodID, x);
-}
-
-void SET_S4_OBJECT(SEXP x) {
-	unimplemented("SET_S4_OBJECT");
-}
-void UNSET_S4_OBJECT(SEXP x) {
-	unimplemented("UNSET_S4_OBJECT");
-}
-
-Rboolean R_ToplevelExec(void (*fun)(void *), void *data) {
-	return (Rboolean) unimplemented("R_ToplevelExec");
-}
-
-SEXP R_ExecWithCleanup(SEXP (*fun)(void *), void *data,
-		       void (*cleanfun)(void *), void *cleandata) {
-	return unimplemented("R_ExecWithCleanup");
-}
-
-#include <R_ext/Connections.h>
-
-SEXP   R_new_custom_connection(const char *description, const char *mode, const char *class_name, Rconnection *ptr) {
-	return unimplemented("R_new_custom_connection");
-}
-
-size_t R_ReadConnection(Rconnection con, void *buf, size_t n) {
-	return (size_t) unimplemented("R_ReadConnection");
-}
-
-size_t R_WriteConnection(Rconnection con, void *buf, size_t n) {
-	return (size_t) unimplemented("R_WriteConnection");
-}
-
-SEXP R_tryEval(SEXP x, SEXP y, int *z) {
-	return unimplemented("R_tryEval");
-}
-
-SEXP R_tryEvalSilent(SEXP x, SEXP y, int *z) {
-	return unimplemented("R_tryEvalSilent");
-}
-
-size_t Riconv (void *cd, const char **inbuf, size_t *inbytesleft,
-	       char **outbuf, size_t *outbytesleft) {
-	return (size_t) unimplemented("Riconv");
-}
-
-int Riconv_close (void *cd) {
-	return (int) unimplemented("Riconv_close");
-	return 0;
-}
-
-void * Riconv_open (const char* tocode, const char* fromcode) {
-	return unimplemented("Riconv_open");
-}
-
-double R_atof(const char *str) {
-	unimplemented("R_atof");
-	return 0;
-}
-
-double R_strtod(const char *c, char **end) {
-	unimplemented("R_strtod");
-	return 0;
-}
-
-
-
-const char *reEnc(const char *x, cetype_t ce_in, cetype_t ce_out, int subst) {
-    // TODO: proper implementation of reEnc
-    return x;
-}
-
-SEXP R_PromiseExpr(SEXP x) {
-	return unimplemented("R_PromiseExpr");
-}
-
-SEXP R_ClosureExpr(SEXP x) {
-	return unimplemented("R_ClosureExpr");
-}
-
-#include <R_ext/Parse.h>
-
-SEXP R_ParseVector(SEXP x, int y, ParseStatus *z, SEXP w) {
-	return unimplemented("R_ParseVector");
-}
-
diff --git a/com.oracle.truffle.r.native/fficall/jni/src/optim.c b/com.oracle.truffle.r.native/fficall/jni/src/optim.c
deleted file mode 100644
index 824e6ac949cad453e4e06c1cf923af317dc98640..0000000000000000000000000000000000000000
--- a/com.oracle.truffle.r.native/fficall/jni/src/optim.c
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright (c) 2015, 2015, 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.
- */
-#include "rffiutils.h"
-
-void init_optim(JNIEnv *env) {
-}
-
-typedef double optimfn(int n, double *par, void *ex);
-typedef void optimgr(int n, double *par, double *gr, void *ex);
-
-void vmmin(int n, double *x, double *Fmin,
-	   optimfn fn, optimgr gr, int maxit, int trace,
-	   int *mask, double abstol, double reltol, int nREPORT,
-	   void *ex, int *fncount, int *grcount, int *fail) {
-	unimplemented("vmmin");
-}
diff --git a/com.oracle.truffle.r.native/fficall/jni/src/rf_functions.c b/com.oracle.truffle.r.native/fficall/jni/src/rf_functions.c
deleted file mode 100644
index 659feaa745a77e8435d9b350ac03c3a17fecc228..0000000000000000000000000000000000000000
--- a/com.oracle.truffle.r.native/fficall/jni/src/rf_functions.c
+++ /dev/null
@@ -1,576 +0,0 @@
-/*
- * Copyright (c) 2015, 2015, 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.
- */
-#include "rffiutils.h"
-#include <string.h>
-
-// Most of the functions with a Rf_ prefix
-// TODO Lots missing yet
-
-static jmethodID Rf_ScalarIntegerMethodID;
-static jmethodID Rf_ScalarDoubleMethodID;
-static jmethodID Rf_ScalarStringMethodID;
-static jmethodID Rf_ScalarLogicalMethodID;
-static jmethodID Rf_allocateVectorMethodID;
-static jmethodID Rf_allocateArrayMethodID;
-static jmethodID Rf_allocateMatrixMethodID;
-static jmethodID Rf_duplicateMethodID;
-static jmethodID Rf_consMethodID;
-static jmethodID Rf_evalMethodID;
-static jmethodID Rf_findfunMethodID;
-static jmethodID Rf_defineVarMethodID;
-static jmethodID Rf_findVarMethodID;
-static jmethodID Rf_findVarInFrameMethodID;
-static jmethodID Rf_getAttribMethodID;
-static jmethodID Rf_setAttribMethodID;
-static jmethodID Rf_isStringMethodID;
-static jmethodID Rf_isNullMethodID;
-static jmethodID Rf_warningcallMethodID;
-static jmethodID Rf_warningMethodID;
-static jmethodID Rf_errorMethodID;
-static jmethodID Rf_NewHashedEnvMethodID;
-static jmethodID Rf_rPsortMethodID;
-static jmethodID Rf_iPsortMethodID;
-static jmethodID RprintfMethodID;
-static jmethodID R_FindNamespaceMethodID;
-static jmethodID Rf_GetOption1MethodID;
-static jmethodID Rf_gsetVarMethodID;
-static jmethodID Rf_inheritsMethodID;
-
-void init_rf_functions(JNIEnv *env) {
-	Rf_ScalarIntegerMethodID = checkGetMethodID(env, CallRFFIHelperClass, "Rf_ScalarInteger", "(I)Lcom/oracle/truffle/r/runtime/data/RIntVector;", 1);
-	Rf_ScalarDoubleMethodID = checkGetMethodID(env, CallRFFIHelperClass, "Rf_ScalarDouble", "(D)Lcom/oracle/truffle/r/runtime/data/RDoubleVector;", 1);
-	Rf_ScalarStringMethodID = checkGetMethodID(env, CallRFFIHelperClass, "Rf_ScalarString", "(Ljava/lang/String;)Lcom/oracle/truffle/r/runtime/data/RStringVector;", 1);
-	Rf_ScalarLogicalMethodID = checkGetMethodID(env, CallRFFIHelperClass, "Rf_ScalarLogical", "(I)Lcom/oracle/truffle/r/runtime/data/RLogicalVector;", 1);
-	Rf_consMethodID = checkGetMethodID(env, CallRFFIHelperClass, "Rf_cons", "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;", 1);
-	Rf_evalMethodID = checkGetMethodID(env, CallRFFIHelperClass, "Rf_eval", "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;", 1);
-	Rf_findfunMethodID = checkGetMethodID(env, CallRFFIHelperClass, "Rf_findfun", "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;", 1);
-	Rf_defineVarMethodID = checkGetMethodID(env, CallRFFIHelperClass, "Rf_defineVar", "(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V", 1);
-	Rf_findVarMethodID = checkGetMethodID(env, CallRFFIHelperClass, "Rf_findVar", "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;", 1);
-	Rf_findVarInFrameMethodID = checkGetMethodID(env, CallRFFIHelperClass, "Rf_findVarInFrame", "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;", 1);
-	Rf_getAttribMethodID = checkGetMethodID(env, CallRFFIHelperClass, "Rf_getAttrib", "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;", 1);
-	Rf_setAttribMethodID = checkGetMethodID(env, CallRFFIHelperClass, "Rf_setAttrib", "(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V", 1);
-	Rf_isStringMethodID = checkGetMethodID(env, CallRFFIHelperClass, "Rf_isString", "(Ljava/lang/Object;)I", 1);
-	Rf_isNullMethodID = checkGetMethodID(env, CallRFFIHelperClass, "Rf_isNull", "(Ljava/lang/Object;)I", 1);
-	Rf_warningMethodID = checkGetMethodID(env, CallRFFIHelperClass, "Rf_warning", "(Ljava/lang/String;)V", 1);
-	Rf_warningcallMethodID = checkGetMethodID(env, CallRFFIHelperClass, "Rf_warningcall", "(Ljava/lang/Object;Ljava/lang/String;)V", 1);
-	Rf_errorMethodID = checkGetMethodID(env, CallRFFIHelperClass, "Rf_error", "(Ljava/lang/String;)V", 1);
-	Rf_allocateVectorMethodID = checkGetMethodID(env, CallRFFIHelperClass, "Rf_allocateVector", "(II)Ljava/lang/Object;", 1);
-	Rf_allocateMatrixMethodID = checkGetMethodID(env, CallRFFIHelperClass, "Rf_allocateMatrix", "(III)Ljava/lang/Object;", 1);
-	Rf_allocateArrayMethodID = checkGetMethodID(env, CallRFFIHelperClass, "Rf_allocateArray", "(ILjava/lang/Object;)Ljava/lang/Object;", 1);
-	Rf_duplicateMethodID = checkGetMethodID(env, CallRFFIHelperClass, "Rf_duplicate", "(Ljava/lang/Object;)Ljava/lang/Object;", 1);
-	Rf_NewHashedEnvMethodID = checkGetMethodID(env, RDataFactoryClass, "createNewEnv", "(Lcom/oracle/truffle/r/runtime/env/REnvironment;Ljava/lang/String;ZI)Lcom/oracle/truffle/r/runtime/env/REnvironment;", 1);
-	RprintfMethodID = checkGetMethodID(env, CallRFFIHelperClass, "printf", "(Ljava/lang/String;)V", 1);
-	R_FindNamespaceMethodID = checkGetMethodID(env, CallRFFIHelperClass, "R_FindNamespace", "(Ljava/lang/Object;)Ljava/lang/Object;", 1);
-	Rf_GetOption1MethodID = checkGetMethodID(env, CallRFFIHelperClass, "Rf_GetOption1", "(Ljava/lang/Object;)Ljava/lang/Object;", 1);
-	Rf_gsetVarMethodID = checkGetMethodID(env, CallRFFIHelperClass, "Rf_gsetVar", "(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V", 1);
-	Rf_inheritsMethodID = checkGetMethodID(env, CallRFFIHelperClass, "Rf_inherits", "(Ljava/lang/Object;Ljava/lang/String;)I", 1);
-//	Rf_rPsortMethodID = checkGetMethodID(env, CallRFFIHelperClass, "Rf_rPsort", "(Lcom/oracle/truffle/r/runtime/data/RDoubleVector;II)", 1);
-//	Rf_iPsortMethodID = checkGetMethodID(env, CallRFFIHelperClass, "Rf_iPsort", "(Lcom/oracle/truffle/r/runtime/data/RIntVector;II)", 1);
-}
-
-SEXP Rf_ScalarInteger(int value) {
-	TRACE("%s(%d)\n", value);
-	JNIEnv *thisenv = getEnv();
-	SEXP result = (*thisenv)->CallStaticObjectMethod(thisenv, CallRFFIHelperClass, Rf_ScalarIntegerMethodID, value);
-    return checkRef(thisenv, result);
-}
-
-SEXP Rf_ScalarReal(double value) {
-	JNIEnv *thisenv = getEnv();
-	SEXP result = (*thisenv)->CallStaticObjectMethod(thisenv, CallRFFIHelperClass, Rf_ScalarDoubleMethodID, value);
-    return checkRef(thisenv, result);
-}
-
-SEXP Rf_ScalarString(SEXP value) {
-	TRACE(TARG1, value);
-	JNIEnv *thisenv = getEnv();
-	SEXP result = (*thisenv)->CallStaticObjectMethod(thisenv, CallRFFIHelperClass, Rf_ScalarStringMethodID, value);
-    return checkRef(thisenv, result);
-}
-
-SEXP Rf_ScalarLogical(int value) {
-	TRACE(TARG1, value);
-	JNIEnv *thisenv = getEnv();
-	SEXP result = (*thisenv)->CallStaticObjectMethod(thisenv, CallRFFIHelperClass, Rf_ScalarLogicalMethodID, value);
-    return checkRef(thisenv, result);
-}
-
-SEXP Rf_allocVector3(SEXPTYPE t, R_xlen_t len, R_allocator_t* allocator) {
-    if (allocator != NULL) {
-	unimplemented("RF_allocVector with custom allocator");
-	return NULL;
-    }
-    TRACE(TARG2d, t, len);
-    JNIEnv *thisenv = getEnv();
-    SEXP result = (*thisenv)->CallStaticObjectMethod(thisenv, CallRFFIHelperClass, Rf_allocateVectorMethodID, t, len);
-    return checkRef(thisenv, result);
-}
-
-SEXP Rf_allocArray(SEXPTYPE t, SEXP dims) {
-	TRACE(TARG2d, t, dims);
-	JNIEnv *thisenv = getEnv();
-	SEXP result = (*thisenv)->CallStaticObjectMethod(thisenv, CallRFFIHelperClass, Rf_allocateArrayMethodID, t, dims);
-	return checkRef(thisenv, result);
-}
-
-SEXP Rf_alloc3DArray(SEXPTYPE t, int x, int y, int z) {
-	return unimplemented("Rf_alloc3DArray");
-}
-
-SEXP Rf_allocMatrix(SEXPTYPE mode, int nrow, int ncol) {
-	TRACE(TARG2d, mode, nrow, ncol);
-	JNIEnv *thisenv = getEnv();
-	SEXP result = (*thisenv)->CallStaticObjectMethod(thisenv, CallRFFIHelperClass, Rf_allocateMatrixMethodID, mode, nrow, ncol);
-	return checkRef(thisenv, result);
-}
-
-SEXP Rf_allocList(int x) {
-	unimplemented("Rf_allocList)");
-	return NULL;
-}
-
-SEXP Rf_allocSExp(SEXPTYPE t) {
-	return unimplemented("Rf_allocSExp");
-}
-
-SEXP Rf_cons(SEXP car, SEXP cdr) {
-	JNIEnv *thisenv = getEnv();
-	SEXP result = (*thisenv)->CallStaticObjectMethod(thisenv, CallRFFIHelperClass, Rf_consMethodID, car, cdr);
-    return checkRef(thisenv, result);
-}
-
-void Rf_defineVar(SEXP symbol, SEXP value, SEXP rho) {
-	JNIEnv *thisenv = getEnv();
-	(*thisenv)->CallStaticObjectMethod(thisenv, CallRFFIHelperClass, Rf_defineVarMethodID, symbol, value, rho);
-}
-
-void Rf_setVar(SEXP x, SEXP y, SEXP z) {
-    unimplemented("Rf_setVar");
-}
-
-SEXP Rf_dimgets(SEXP x, SEXP y) {
-	return unimplemented("Rf_dimgets");
-}
-
-SEXP Rf_dimnamesgets(SEXP x, SEXP y) {
-	return unimplemented("Rf_dimnamesgets");
-}
-
-SEXP Rf_eval(SEXP expr, SEXP env) {
-    JNIEnv *thisenv = getEnv();
-    SEXP result = (*thisenv)->CallStaticObjectMethod(thisenv, CallRFFIHelperClass, Rf_evalMethodID, expr, env);
-    return checkRef(thisenv, result);
-}
-
-SEXP Rf_findFun(SEXP symbol, SEXP rho) {
-	JNIEnv *thisenv = getEnv();
-	SEXP result = (*thisenv)->CallStaticObjectMethod(thisenv, CallRFFIHelperClass, Rf_findfunMethodID, symbol, rho);
-	return checkRef(thisenv, result);
-}
-
-SEXP Rf_findVar(SEXP symbol, SEXP rho) {
-	JNIEnv *thisenv = getEnv();
-	SEXP result =(*thisenv)->CallStaticObjectMethod(thisenv, CallRFFIHelperClass, Rf_findVarMethodID, symbol, rho);
-    return checkRef(thisenv, result);
-}
-
-SEXP Rf_findVarInFrame(SEXP symbol, SEXP rho) {
-	JNIEnv *thisenv = getEnv();
-	SEXP result =(*thisenv)->CallStaticObjectMethod(thisenv, CallRFFIHelperClass, Rf_findVarInFrameMethodID, symbol, rho);
-    return checkRef(thisenv, result);
-}
-
-SEXP Rf_getAttrib(SEXP vec, SEXP name) {
-	JNIEnv *thisenv = getEnv();
-	SEXP result = (*thisenv)->CallStaticObjectMethod(thisenv, CallRFFIHelperClass, Rf_getAttribMethodID, vec, name);
-	return checkRef(thisenv, result);
-}
-
-SEXP Rf_setAttrib(SEXP vec, SEXP name, SEXP val) {
-	JNIEnv *thisenv = getEnv();
-	(*thisenv)->CallStaticObjectMethod(thisenv, CallRFFIHelperClass, Rf_setAttribMethodID, vec, name, val);
-	return val;
-}
-
-SEXP Rf_duplicate(SEXP x) {
-	JNIEnv *thisenv = getEnv();
-	SEXP result = (*thisenv)->CallStaticObjectMethod(thisenv, CallRFFIHelperClass, Rf_duplicateMethodID, x);
-	return checkRef(thisenv, result);
-}
-
-R_xlen_t Rf_any_duplicated(SEXP x, Rboolean from_last) {
-	unimplemented("Rf_any_duplicated");
-	return 0;
-}
-
-SEXP Rf_duplicated(SEXP x, Rboolean y) {
-	unimplemented("Rf_duplicated");
-	return NULL;
-}
-
-void Rf_copyMostAttrib(SEXP x, SEXP y) {
-	unimplemented("Rf_copyMostAttrib");
-}
-
-Rboolean Rf_inherits(SEXP x, const char * klass) {
-    JNIEnv *thisenv = getEnv();
-    jstring klazz = (*thisenv)->NewStringUTF(thisenv, klass);
-    return (*thisenv)->CallStaticIntMethod(thisenv, CallRFFIHelperClass, Rf_inheritsMethodID, x, klazz);
-}
-
-Rboolean Rf_isReal(SEXP x) {
-    return TYPEOF(x) == REALSXP;
-}
-
-Rboolean Rf_isSymbol(SEXP x) {
-    return TYPEOF(x) == SYMSXP;
-}
-
-Rboolean Rf_isComplex(SEXP x) {
-    return TYPEOF(x) == CPLXSXP;
-}
-
-Rboolean Rf_isEnvironment(SEXP x) {
-    return TYPEOF(x) == ENVSXP;
-}
-
-Rboolean Rf_isExpression(SEXP x) {
-    return TYPEOF(x) == EXPRSXP;
-}
-
-Rboolean Rf_isLogical(SEXP x) {
-    return TYPEOF(x) == LGLSXP;
-}
-
-Rboolean Rf_isObject(SEXP s) {
-	unimplemented("Rf_isObject");
-	return FALSE;
-}
-
-SEXP Rf_install(const char *name) {
-	JNIEnv *thisenv = getEnv();
-	jstring string = (*thisenv)->NewStringUTF(thisenv, name);
-	SEXP result = (*thisenv)->CallStaticObjectMethod(thisenv, CallRFFIHelperClass, createSymbolMethodID, string);
-	return checkRef(thisenv, result);
-}
-
-Rboolean Rf_isNull(SEXP s) {
-	JNIEnv *thisenv = getEnv();
-	return (*thisenv)->CallStaticIntMethod(thisenv, CallRFFIHelperClass, Rf_isNullMethodID, s);
-}
-
-Rboolean Rf_isString(SEXP s) {
-	JNIEnv *thisenv = getEnv();
-	return (*thisenv)->CallStaticIntMethod(thisenv, CallRFFIHelperClass, Rf_isStringMethodID, s);
-}
-
-cetype_t Rf_getCharCE(SEXP x) {
-    // unimplemented("Rf_getCharCE");
-    // TODO: real implementation
-    return CE_NATIVE;
-}
-
-SEXP Rf_mkChar(const char *x) {
-	JNIEnv *thisenv = getEnv();
-	// TODO encoding, assume UTF for now
-	SEXP result = (*thisenv)->NewStringUTF(thisenv, x);
-	return checkRef(thisenv, result);
-}
-
-SEXP Rf_mkCharCE(const char *x, cetype_t y) {
-	unimplemented("Rf_mkCharCE");
-	return NULL;
-}
-
-SEXP Rf_mkCharLen(const char *x, int y) {
-	return unimplemented("Rf_mkCharLen");
-}
-
-SEXP Rf_mkCharLenCE(const char *x, int len, cetype_t enc) {
-	JNIEnv *thisenv = getEnv();
-	char buf[len + 1];
-	memcpy(buf, x, len);
-	buf[len] = 0;
-	// TODO encoding, assume UTF for now, zero terminated
-	SEXP result = (*thisenv)->NewStringUTF(thisenv, buf);
-	return checkRef(thisenv, result);
-}
-
-SEXP Rf_mkString(const char *s) {
-	JNIEnv *thisenv = getEnv();
-	jstring string = (*thisenv)->NewStringUTF(thisenv, s);
-	return ScalarString(string);
-}
-
-int Rf_ncols(SEXP x) {
-	unimplemented("Rf_ncols");
-	return 0;
-}
-
-int Rf_nrows(SEXP x) {
-	unimplemented("Rf_nrows");
-	return 0;
-}
-
-
-SEXP Rf_protect(SEXP x) {
-	return x;
-}
-
-void Rf_unprotect(int x) {
-	// TODO perhaps we can use this
-}
-
-void R_ProtectWithIndex(SEXP x, PROTECT_INDEX *y) {
-
-}
-
-void R_Reprotect(SEXP x, PROTECT_INDEX y) {
-
-}
-
-
-void Rf_unprotect_ptr(SEXP x) {
-	// TODO perhaps we can use this
-}
-
-#define BUFSIZE 8192
-
-static int Rvsnprintf(char *buf, size_t size, const char  *format, va_list ap)
-{
-    int val;
-    val = vsnprintf(buf, size, format, ap);
-    buf[size-1] = '\0';
-    return val;
-}
-
-
-void Rf_error(const char *format, ...) {
-	// This is a bit tricky. The usual error handling model in Java is "throw RError.error(...)" but
-	// RError.error does quite a lot of stuff including potentially searching for R condition handlers
-	// and, if it finds any, does not return, but throws a different exception than RError.
-	// We definitely need to exit the FFI call and we certainly cannot return to our caller.
-	// So we call CallRFFIHelper.Rf_error to throw the RError exception. When the pending
-	// exception (whatever it is) is observed by JNI, the call to Rf_error will return where we do a
-	// non-local transfer of control back to the entry point (which will cleanup).
-	char buf[8192];
-	va_list(ap);
-	va_start(ap,format);
-	Rvsnprintf(buf, BUFSIZE - 1, format, ap);
-	va_end(ap);
-	JNIEnv *thisenv = getEnv();
-	jstring string = (*thisenv)->NewStringUTF(thisenv, buf);
-	// This will set a pending exception
-	(*thisenv)->CallStaticObjectMethod(thisenv, CallRFFIHelperClass, Rf_errorMethodID, string);
-	// just transfer back which will cleanup and exit the entire JNI call
-	longjmp(*getErrorJmpBuf(), 1);
-
-}
-
-void Rf_warningcall(SEXP x, const char *format, ...) {
-	char buf[8192];
-	va_list(ap);
-	va_start(ap,format);
-	Rvsnprintf(buf, BUFSIZE - 1, format, ap);
-	va_end(ap);
-	JNIEnv *thisenv = getEnv();
-	jstring string = (*thisenv)->NewStringUTF(thisenv, buf);
-	(*thisenv)->CallStaticObjectMethod(thisenv, CallRFFIHelperClass, Rf_warningcallMethodID, x, string);
-}
-
-void Rf_warning(const char *format, ...) {
-	char buf[8192];
-	va_list(ap);
-	va_start(ap,format);
-	Rvsnprintf(buf, BUFSIZE - 1, format, ap);
-	va_end(ap);
-	JNIEnv *thisenv = getEnv();
-	jstring string = (*thisenv)->NewStringUTF(thisenv, buf);
-	(*thisenv)->CallStaticObjectMethod(thisenv, CallRFFIHelperClass, Rf_warningMethodID, string);
-}
-
-void Rprintf(const char *format, ...) {
-	char buf[8192];
-	va_list(ap);
-	va_start(ap,format);
-	Rvsnprintf(buf, BUFSIZE - 1, format, ap);
-	va_end(ap);
-	JNIEnv *thisenv = getEnv();
-	jstring string = (*thisenv)->NewStringUTF(thisenv, buf);
-	(*thisenv)->CallStaticObjectMethod(thisenv, CallRFFIHelperClass, RprintfMethodID, string);
-}
-
-/*
-  REprintf is used by the error handler do not add
-  anything unless you're sure it won't
-  cause problems
-*/
-void REprintf(const char *format, ...)
-{
-	// TODO: determine correct target for this message
-	char buf[8192];
-	va_list(ap);
-	va_start(ap,format);
-	Rvsnprintf(buf, BUFSIZE - 1, format, ap);
-	va_end(ap);
-	JNIEnv *thisenv = getEnv();
-	jstring string = (*thisenv)->NewStringUTF(thisenv, buf);
-	(*thisenv)->CallStaticObjectMethod(thisenv, CallRFFIHelperClass, RprintfMethodID, string);
-}
-
-void Rvprintf(const char *format, va_list args) {
-	unimplemented("Rvprintf");
-}
-void REvprintf(const char *format, va_list args) {
-	unimplemented("REvprintf");
-}
-
-void R_FlushConsole(void) {
-	// ignored
-}
-
-// Tools package support, not in public API
-
-SEXP R_NewHashedEnv(SEXP parent, SEXP size) {
-	JNIEnv *thisenv = getEnv();
-	int sizeAsInt = Rf_asInteger(size);
-	SEXP result = (*thisenv)->CallStaticObjectMethod(thisenv, RDataFactoryClass, Rf_NewHashedEnvMethodID, parent, NULL, JNI_TRUE, sizeAsInt);
-	return checkRef(thisenv, result);
-}
-
-SEXP Rf_classgets(SEXP x, SEXP y) {
-	unimplemented("Rf_classgets");
-	return NULL;
-}
-
-const char *Rf_translateChar(SEXP x) {
-//	unimplemented("Rf_translateChar");
-	// TODO: proper implementation
-	const char *result = CHAR(x);
-//	printf("translateChar: '%s'\n", result);
-	return result;
-}
-
-const char *Rf_translateChar0(SEXP x) {
-	unimplemented("Rf_translateChar0");
-	return NULL;
-}
-
-const char *Rf_translateCharUTF8(SEXP x) {
-	unimplemented("Rf_translateCharUTF8");
-	return NULL;
-}
-
-const char *Rf_type2char(SEXPTYPE x) {
-	unimplemented("Rf_type2char");
-	return NULL;
-}
-
-SEXP Rf_type2str(SEXPTYPE x) {
-	unimplemented("Rf_type2str");
-	return R_NilValue;
-	return NULL;
-}
-
-SEXP R_FindNamespace(SEXP info) {
-	JNIEnv *thisenv = getEnv();
-	SEXP result = (*thisenv)->CallStaticObjectMethod(thisenv, CallRFFIHelperClass, R_FindNamespaceMethodID, info);
-	return checkRef(thisenv, result);
-}
-
-SEXP Rf_lengthgets(SEXP x, R_len_t y) {
-	return unimplemented("Rf_lengthgets");
-}
-
-SEXP Rf_xlengthgets(SEXP x, R_xlen_t y) {
-	return unimplemented("Rf_xlengthgets");
-
-}
-
-SEXP Rf_namesgets(SEXP x, SEXP y) {
-	return unimplemented("Rf_namesgets");
-}
-
-SEXP GetOption1(SEXP tag)
-{
-	JNIEnv *thisenv = getEnv();
-	SEXP result = (*thisenv)->CallStaticObjectMethod(thisenv, CallRFFIHelperClass, Rf_GetOption1MethodID, tag);
-	return checkRef(thisenv, result);
-}
-
-int GetOptionCutoff(void)
-{
-    int w;
-    w = asInteger(GetOption1(install("deparse.cutoff")));
-    if (w == NA_INTEGER || w <= 0) {
-	warning(_("invalid 'deparse.cutoff', used 60"));
-	w = 60;
-    }
-    return w;
-}
-
-#define R_MIN_WIDTH_OPT		10
-#define R_MAX_WIDTH_OPT		10000
-#define R_MIN_DIGITS_OPT	0
-#define R_MAX_DIGITS_OPT	22
-
-int GetOptionWidth(void)
-{
-    int w;
-    w = asInteger(GetOption1(install("width")));
-    if (w < R_MIN_WIDTH_OPT || w > R_MAX_WIDTH_OPT) {
-	warning(_("invalid printing width, used 80"));
-	return 80;
-    }
-    return w;
-}
-
-int GetOptionDigits(void)
-{
-    int d;
-    d = asInteger(GetOption1(install("digits")));
-    if (d < R_MIN_DIGITS_OPT || d > R_MAX_DIGITS_OPT) {
-	warning(_("invalid printing digits, used 7"));
-	return 7;
-    }
-    return d;
-}
-
-Rboolean Rf_GetOptionDeviceAsk(void)
-{
-    int ask;
-    ask = asLogical(GetOption1(install("device.ask.default")));
-    if(ask == NA_LOGICAL) {
-	warning(_("invalid value for \"device.ask.default\", using FALSE"));
-	return FALSE;
-    }
-    return ask != 0;
-}
-
-void Rf_gsetVar(SEXP symbol, SEXP value, SEXP rho)
-{
-	JNIEnv *thisenv = getEnv();
-	(*thisenv)->CallStaticObjectMethod(thisenv, CallRFFIHelperClass, Rf_gsetVarMethodID, symbol, value, rho);
-}
-
-
diff --git a/com.oracle.truffle.r.native/fficall/jni/src/rfficall.c b/com.oracle.truffle.r.native/fficall/jni/src/rfficall.c
index 30b78ec6aafcac1fff8add78694b974183a662d5..4d42bd864f1dbff84b4fc9a322e2185689e1c212 100644
--- a/com.oracle.truffle.r.native/fficall/jni/src/rfficall.c
+++ b/com.oracle.truffle.r.native/fficall/jni/src/rfficall.c
@@ -30,17 +30,10 @@ Java_com_oracle_truffle_r_runtime_ffi_jnr_JNI_1CallRFFI_initialize(JNIEnv *env,
 		jobjectArray initialValues) {
 	init_utils(env); // must be first
 	init_variables(env, initialValues);
-	init_register(env);
-	init_rf_functions(env);
-	init_externalptr(env);
-	init_typecoerce(env);
-	init_attrib(env);
-	init_misc(env);
+	init_dynload(env);
+	init_internals(env);
 	init_rmath(env);
-	init_rng(env);
-	init_optim(env);
-	init_vectoraccess(env);
-	init_listaccess(env);
+	init_random(env);
 }
 
 JNIEXPORT void JNICALL
diff --git a/com.oracle.truffle.r.native/fficall/jni/src/rffiutils.h b/com.oracle.truffle.r.native/fficall/jni/src/rffiutils.h
index 47f4e5235d4be88ca921f14539a55c63351b5c37..9cd0cd4c25d55ef437d63b2ff1eec883f75b88be 100644
--- a/com.oracle.truffle.r.native/fficall/jni/src/rffiutils.h
+++ b/com.oracle.truffle.r.native/fficall/jni/src/rffiutils.h
@@ -68,16 +68,9 @@ void addCopiedObject(JNIEnv *env, SEXP x, SEXPTYPE type, void *jArray, void *dat
 
 void init_rmath(JNIEnv *env);
 void init_variables(JNIEnv *env, jobjectArray initialValues);
-void init_register(JNIEnv *env);
-void init_rf_functions(JNIEnv *env);
-void init_externalptr(JNIEnv *env);
-void init_typecoerce(JNIEnv *env);
-void init_attrib(JNIEnv *env);
-void init_misc(JNIEnv *env);
-void init_rng(JNIEnv *env);
-void init_optim(JNIEnv *env);
-void init_vectoraccess(JNIEnv *env);
-void init_listaccess(JNIEnv *env);
+void init_dynload(JNIEnv *env);
+void init_internals(JNIEnv *env);
+void init_random(JNIEnv *env);
 void init_utils(JNIEnv *env);
 
 void setTempDir(JNIEnv *, jstring tempDir);
diff --git a/com.oracle.truffle.r.native/fficall/jni/src/variables.c b/com.oracle.truffle.r.native/fficall/jni/src/variables.c
index c461839e551d6b22a85769fed57d161e60d43155..f3e04dad94ef14375d70813c6c07a168d731307d 100644
--- a/com.oracle.truffle.r.native/fficall/jni/src/variables.c
+++ b/com.oracle.truffle.r.native/fficall/jni/src/variables.c
@@ -29,85 +29,7 @@
 #include <jni.h>
 #include <Rinternals.h>
 #include "rffiutils.h"
-
-
-/* Evaluation Environment */
-//SEXP R_GlobalEnv;
-SEXP R_EmptyEnv;
-//SEXP R_BaseEnv;
-//SEXP R_BaseNamespace;
-//SEXP R_NamespaceRegistry;
-
-//SEXP R_Srcref;
-
-/* Special Values */
-SEXP R_NilValue;
-SEXP R_UnboundValue;
-SEXP R_MissingArg;
-
-/* Symbol Table Shortcuts */
-SEXP R_Bracket2Symbol;   /* "[[" */
-SEXP R_BracketSymbol;    /* "[" */
-SEXP R_BraceSymbol;      /* "{" */
-SEXP R_ClassSymbol;     /* "class" */
-SEXP R_DeviceSymbol;     /* ".Device" */
-SEXP R_DevicesSymbol;     /* ".Devices" */
-SEXP R_DimNamesSymbol;   /* "dimnames" */
-SEXP R_DimSymbol;     /* "dim" */
-SEXP R_DollarSymbol;     /* "$" */
-SEXP R_DotsSymbol;     /* "..." */
-SEXP R_DropSymbol;     /* "drop" */
-SEXP R_LastvalueSymbol;  /* ".Last.value" */
-SEXP R_LevelsSymbol;     /* "levels" */
-SEXP R_ModeSymbol;     /* "mode" */
-SEXP R_NameSymbol;     /* "name" */
-SEXP R_NamesSymbol;     /* "names" */
-SEXP R_NaRmSymbol;     /* "na.rm" */
-SEXP R_PackageSymbol;    /* "package" */
-SEXP R_QuoteSymbol;     /* "quote" */
-SEXP R_RowNamesSymbol;   /* "row.names" */
-SEXP R_SeedsSymbol;     /* ".Random.seed" */
-SEXP R_SourceSymbol;     /* "source" */
-SEXP R_TspSymbol;     /* "tsp" */
-
-SEXP R_dot_defined;      /* ".defined" */
-SEXP R_dot_Method;       /* ".Method" */
-SEXP R_dot_target;       /* ".target" */
-SEXP R_NaString;	    /* NA_STRING as a CHARSXP */
-SEXP R_BlankString;	    /* "" as a CHARSXP */
-
-// Symbols not part of public API but used in FastR tools implementation
-SEXP R_SrcrefSymbol;
-SEXP R_SrcfileSymbol;
-
-// logical constants
-SEXP R_TrueValue;
-SEXP R_FalseValue;
-SEXP R_LogicalNAValue;
-
-// Arith.h
-double R_NaN;		/* IEEE NaN */
-double R_PosInf;	/* IEEE Inf */
-double R_NegInf;	/* IEEE -Inf */
-double R_NaReal;	/* NA_REAL: IEEE */
-int R_NaInt;	/* NA_INTEGER:= INT_MIN currently */
-
-// from Defn.h
-const char* R_Home;
-const char* R_TempDir;
-
-// various ignored flags and variables:
-Rboolean R_Visible;
-Rboolean R_Interactive;
-Rboolean R_interrupts_suspended;
-int R_interrupts_pending;
-Rboolean mbcslocale;
-Rboolean useaqua;
-char OutDec = '.';
-Rboolean utf8locale = FALSE;
-Rboolean mbcslocale = FALSE;
-Rboolean latin1locale = FALSE;
-int R_dec_min_exponent = -308;
+#include "../../common/src/variable_defs.h"
 
 jmethodID getGlobalEnvMethodID;
 jmethodID getBaseEnvMethodID;
diff --git a/com.oracle.truffle.r.native/fficall/jni/src/vectoraccess.c b/com.oracle.truffle.r.native/fficall/jni/src/vectoraccess.c
deleted file mode 100644
index 723e3ba7d603c8730f95aee55d265638c18226d9..0000000000000000000000000000000000000000
--- a/com.oracle.truffle.r.native/fficall/jni/src/vectoraccess.c
+++ /dev/null
@@ -1,196 +0,0 @@
-/*
- * Copyright (c) 2015, 2015, 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.
- */
-#include "rffiutils.h"
-#include <stdlib.h>
-#include <string.h>
-
-jmethodID SET_STRING_ELT_MethodID;
-jmethodID SET_VECTOR_ELT_MethodID;
-jmethodID RAW_MethodID;
-jmethodID INTEGER_MethodID;
-jmethodID REAL_MethodID;
-jmethodID LOGICAL_MethodID;
-jmethodID STRING_ELT_MethodID;
-jmethodID VECTOR_ELT_MethodID;
-jmethodID LENGTH_MethodID;
-
-void init_vectoraccess(JNIEnv *env) {
-	SET_STRING_ELT_MethodID = checkGetMethodID(env, CallRFFIHelperClass, "SET_STRING_ELT", "(Ljava/lang/Object;ILjava/lang/Object;)V", 1);
-	SET_VECTOR_ELT_MethodID = checkGetMethodID(env, CallRFFIHelperClass, "SET_VECTOR_ELT", "(Ljava/lang/Object;ILjava/lang/Object;)V", 1);
-	RAW_MethodID = checkGetMethodID(env, CallRFFIHelperClass, "RAW", "(Ljava/lang/Object;)[B", 1);
-	REAL_MethodID = checkGetMethodID(env, CallRFFIHelperClass, "REAL", "(Ljava/lang/Object;)[D", 1);
-	LOGICAL_MethodID = checkGetMethodID(env, CallRFFIHelperClass, "LOGICAL", "(Ljava/lang/Object;)[I", 1);
-	INTEGER_MethodID = checkGetMethodID(env, CallRFFIHelperClass, "INTEGER", "(Ljava/lang/Object;)[I", 1);
-	STRING_ELT_MethodID = checkGetMethodID(env, CallRFFIHelperClass, "STRING_ELT", "(Ljava/lang/Object;I)Ljava/lang/String;", 1);
-	VECTOR_ELT_MethodID = checkGetMethodID(env, CallRFFIHelperClass, "VECTOR_ELT", "(Ljava/lang/Object;I)Ljava/lang/Object;", 1);
-	LENGTH_MethodID = checkGetMethodID(env, CallRFFIHelperClass, "LENGTH", "(Ljava/lang/Object;)I", 1);
-}
-
-int LENGTH(SEXP x) {
-    TRACE(TARG1, x);
-    JNIEnv *thisenv = getEnv();
-    return (*thisenv)->CallStaticIntMethod(thisenv, CallRFFIHelperClass, LENGTH_MethodID, x);
-}
-
-int TRUELENGTH(SEXP x){
-    unimplemented("unimplemented");
-    return 0;
-}
-
-
-void SETLENGTH(SEXP x, int v){
-    unimplemented("SETLENGTH");
-}
-
-
-void SET_TRUELENGTH(SEXP x, int v){
-    unimplemented("SET_TRUELENGTH");
-}
-
-
-R_xlen_t XLENGTH(SEXP x){
-    // xlength seems to be used for long vectors (no such thing in FastR at the moment)
-    return LENGTH(x);
-}
-
-
-R_xlen_t XTRUELENGTH(SEXP x){
-	unimplemented("XTRUELENGTH");
-	return 0;
-}
-
-
-int IS_LONG_VEC(SEXP x){
-	unimplemented("IS_LONG_VEC");
-	return 0;
-}
-
-
-int LEVELS(SEXP x){
-	unimplemented("LEVELS");
-	return 0;
-}
-
-
-int SETLEVELS(SEXP x, int v){
-	unimplemented("SETLEVELS");
-	return 0;
-}
-
-int *LOGICAL(SEXP x){
-	TRACE(TARG1, x);
-	JNIEnv *thisenv = getEnv();
-	jint *data = (jint *) findCopiedObject(thisenv, x);
-	if (data == NULL) {
-	    jintArray intArray = (*thisenv)->CallStaticObjectMethod(thisenv, CallRFFIHelperClass, LOGICAL_MethodID, x);
-	    int len = (*thisenv)->GetArrayLength(thisenv, intArray);
-	    data = (*thisenv)->GetIntArrayElements(thisenv, intArray, NULL);
-	    addCopiedObject(thisenv, x, LGLSXP, intArray, data);
-	}
-	return data;
-}
-
-int *INTEGER(SEXP x){
-	TRACE(TARG1, x);
-	JNIEnv *thisenv = getEnv();
-	jint *data = (jint *) findCopiedObject(thisenv, x);
-	if (data == NULL) {
-	    jintArray intArray = (*thisenv)->CallStaticObjectMethod(thisenv, CallRFFIHelperClass, INTEGER_MethodID, x);
-	    int len = (*thisenv)->GetArrayLength(thisenv, intArray);
-	    data = (*thisenv)->GetIntArrayElements(thisenv, intArray, NULL);
-	    addCopiedObject(thisenv, x, INTSXP, intArray, data);
-	}
-	return data;
-}
-
-
-Rbyte *RAW(SEXP x){
-	JNIEnv *thisenv = getEnv();
-	jbyte *data = (jbyte *) findCopiedObject(thisenv, x);
-	if (data == NULL) {
-	    jbyteArray byteArray = (*thisenv)->CallStaticObjectMethod(thisenv, CallRFFIHelperClass, RAW_MethodID, x);
-	    int len = (*thisenv)->GetArrayLength(thisenv, byteArray);
-	    data = (*thisenv)->GetByteArrayElements(thisenv, byteArray, NULL);
-        addCopiedObject(thisenv, x, RAWSXP, byteArray, data);
-    }
-	return (Rbyte*) data;
-}
-
-
-double *REAL(SEXP x){
-    JNIEnv *thisenv = getEnv();
-    jdouble *data = (jdouble *) findCopiedObject(thisenv, x);
-    if (data == NULL) {
-	jdoubleArray doubleArray = (*thisenv)->CallStaticObjectMethod(thisenv, CallRFFIHelperClass, REAL_MethodID, x);
-	int len = (*thisenv)->GetArrayLength(thisenv, doubleArray);
-	data = (*thisenv)->GetDoubleArrayElements(thisenv, doubleArray, NULL);
-	addCopiedObject(thisenv, x, REALSXP, doubleArray, data);
-    }
-    return data;
-}
-
-
-Rcomplex *COMPLEX(SEXP x){
-	unimplemented("COMPLEX");
-	return NULL;
-}
-
-
-SEXP STRING_ELT(SEXP x, R_xlen_t i){
-	TRACE(TARG2d, x, i);
-	JNIEnv *thisenv = getEnv();
-    SEXP result = (*thisenv)->CallStaticObjectMethod(thisenv, CallRFFIHelperClass, STRING_ELT_MethodID, x, i);
-    return checkRef(thisenv, result);
-}
-
-
-SEXP VECTOR_ELT(SEXP x, R_xlen_t i){
-	JNIEnv *thisenv = getEnv();
-    SEXP result = (*thisenv)->CallStaticObjectMethod(thisenv, CallRFFIHelperClass, VECTOR_ELT_MethodID, x, i);
-    return checkRef(thisenv, result);
-}
-
-void SET_STRING_ELT(SEXP x, R_xlen_t i, SEXP v){
-	JNIEnv *thisenv = getEnv();
-	(*thisenv)->CallStaticVoidMethod(thisenv, CallRFFIHelperClass, SET_STRING_ELT_MethodID, x, i, v);
-}
-
-
-SEXP SET_VECTOR_ELT(SEXP x, R_xlen_t i, SEXP v){
-	JNIEnv *thisenv = getEnv();
-	(*thisenv)->CallStaticVoidMethod(thisenv, CallRFFIHelperClass, SET_VECTOR_ELT_MethodID, x, i, v);
-	return v;
-}
-
-
-SEXP *STRING_PTR(SEXP x){
-	unimplemented("STRING_PTR");
-	return NULL;
-}
-
-
-SEXP *VECTOR_PTR(SEXP x){
-	unimplemented("VECTOR_PTR");
-	return NULL;
-}
-