diff --git a/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/TruffleRLanguage.java b/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/TruffleRLanguage.java
index efa8c2604598ef683d1f30b6464ee83c8798e479..10c991e6188eb081186fcf5296987bc3f7106ff1 100644
--- a/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/TruffleRLanguage.java
+++ b/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/TruffleRLanguage.java
@@ -58,14 +58,20 @@ public final class TruffleRLanguage extends TruffleLanguage<RContext> {
     private static synchronized void initialize() {
         if (!initialized) {
             initialized = true;
-            Load_RFFIFactory.initialize();
-            RInstrument.initialize();
-            RPerfStats.initialize();
-            Locale.setDefault(Locale.ROOT);
-            RAccuracyInfo.initialize();
-            RVersionInfo.initialize();
-            TempPathName.initialize();
-            RContext.initialize(new RRuntimeASTAccessImpl(), RBuiltinPackages.getInstance());
+            try {
+                Load_RFFIFactory.initialize();
+                RInstrument.initialize();
+                RPerfStats.initialize();
+                Locale.setDefault(Locale.ROOT);
+                RAccuracyInfo.initialize();
+                RVersionInfo.initialize();
+                TempPathName.initialize();
+                RContext.initialize(new RRuntimeASTAccessImpl(), RBuiltinPackages.getInstance());
+            } catch (Throwable t) {
+                System.out.println("error during engine initialization:");
+                t.printStackTrace();
+                System.exit(-1);
+            }
         }
     }
 
diff --git a/com.oracle.truffle.r.native/fficall/jni/Makefile b/com.oracle.truffle.r.native/fficall/jni/Makefile
index 95fa6bf3faccf19d7f4d1f9ee2a349f92a56e83a..e73e29b3590650019a4c36a6f26fd1a8184b6865 100644
--- a/com.oracle.truffle.r.native/fficall/jni/Makefile
+++ b/com.oracle.truffle.r.native/fficall/jni/Makefile
@@ -40,7 +40,7 @@ C_OBJECTS := $(subst $(SRC),$(OBJ),$(C_SOURCES:.c=.o))
 C_LIB := $(TOPDIR)/../lib/$(C_LIBNAME)
 
 JNI_INCLUDES = -I $(JAVA_HOME)/include -I $(JAVA_HOME)/include/$(JDK_OS_DIR)
-FFI_INCLUDES = -I$(TOPDIR)/include/jni/include -I$(TOPDIR)/include/jni/include/R_ext
+FFI_INCLUDES = -I$(TOPDIR)/include/jni/include -I$(TOPDIR)/gnur/R-3.1.3/src/include -I$(TOPDIR)/include/jni/include/R_ext
 
 INCLUDES := $(JNI_INCLUDES) $(FFI_INCLUDES)
 
diff --git a/com.oracle.truffle.r.native/fficall/jni/src/Defn.h b/com.oracle.truffle.r.native/fficall/jni/src/Defn.h
new file mode 100644
index 0000000000000000000000000000000000000000..da43dd42f3068ac3e423dd2f302d331b346c30d9
--- /dev/null
+++ b/com.oracle.truffle.r.native/fficall/jni/src/Defn.h
@@ -0,0 +1,46 @@
+/*
+ * 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.
+ */
+
+#define DEFN_H_
+
+#include <jni.h>
+#include <stdlib.h>
+#include <Rinternals.h>
+
+// various definitions required to compile GNU-R code:
+#define F77_SYMBOL(x)	x
+#define F77_QSYMBOL(x) #x
+
+#define Rexp10(x) pow(10.0, x)
+
+// no NLS:
+#ifndef _
+#define _(String) (String)
+#endif
+#define N_(String) String
+#define ngettext(String, StringP, N) (N > 1 ? StringP: String)
+
+void sortVector(SEXP, Rboolean);
+int Scollate(SEXP a, SEXP b);
+void Rf_checkArityCall(SEXP, SEXP, SEXP);
+
diff --git a/com.oracle.truffle.r.native/fficall/jni/src/graphicsengine.c b/com.oracle.truffle.r.native/fficall/jni/src/graphicsengine.c
index 4203767ff6b228104063bcfa8ed80402661c6dd3..e33fd21b515251a057fb4d3338312f175d8a4da7 100644
--- a/com.oracle.truffle.r.native/fficall/jni/src/graphicsengine.c
+++ b/com.oracle.truffle.r.native/fficall/jni/src/graphicsengine.c
@@ -151,7 +151,8 @@ int GEstring_to_pch(SEXP pch) {
 }
 
 unsigned int GE_LTYpar(SEXP x, int y) {
-    return unimplemented("GE_LTYpar");
+    unimplemented("GE_LTYpar");
+    return 0;
 }
 
 SEXP GE_LTYget(unsigned int x) {
@@ -393,16 +394,3 @@ double toDeviceHeight(double value, GEUnit from, pGEDevDesc dd) {
     unimplemented("toDeviceHeight");
     return 0.0;
 }
-
-rcolor Rf_RGBpar(SEXP x, int y) {
-	return (rcolor) unimplemented("RGBpar");
-}
-
-rcolor Rf_RGBpar3(SEXP x, int y, rcolor z) {
-    return (rcolor) unimplemented("RGBpar3");
-}
-
-
-const char *Rf_col2name(rcolor col) {
-    return (const char *) unimplemented("col2name");
-}
diff --git a/com.oracle.truffle.r.native/fficall/jni/src/main_colors.c b/com.oracle.truffle.r.native/fficall/jni/src/main_colors.c
new file mode 100644
index 0000000000000000000000000000000000000000..bf5763495a3b506abd2d4bd4be25f017a91ea8ac
--- /dev/null
+++ b/com.oracle.truffle.r.native/fficall/jni/src/main_colors.c
@@ -0,0 +1,28 @@
+/*
+ * 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.
+ */
+
+#define attribute_hidden
+
+#include "Defn.h"
+
+#include "../../../gnur/R-3.1.3/src/main/colors.c"
diff --git a/com.oracle.truffle.r.native/fficall/jni/src/main_format.c b/com.oracle.truffle.r.native/fficall/jni/src/main_format.c
new file mode 100644
index 0000000000000000000000000000000000000000..f677ed0b4c635bbd83cd79a3df5698549324b631
--- /dev/null
+++ b/com.oracle.truffle.r.native/fficall/jni/src/main_format.c
@@ -0,0 +1,31 @@
+/*
+ * 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.
+ */
+
+#define HAVE_NEARBYINT
+#define attribute_hidden
+
+extern int R_dec_min_exponent;
+
+#include "Defn.h"
+
+#include "../../../gnur/R-3.1.3/src/main/format.c"
diff --git a/com.oracle.truffle.r.native/fficall/jni/src/main_print.c b/com.oracle.truffle.r.native/fficall/jni/src/main_print.c
new file mode 100644
index 0000000000000000000000000000000000000000..eb897e5156aa93e8e98bfb6573854127d0de46b2
--- /dev/null
+++ b/com.oracle.truffle.r.native/fficall/jni/src/main_print.c
@@ -0,0 +1,133 @@
+/*
+ * 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"
+
+// the following code is copied from "print.c"
+
+/*
+ *  R : A Computer Language for Statistical Data Analysis
+ *  Copyright (C) 1995-1998	Robert Gentleman and Ross Ihaka.
+ *  Copyright (C) 2000-2012	The R Core Team.
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program 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 for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, a copy is available at
+ *  http://www.r-project.org/Licenses/
+ *
+ *
+ *  print.default()  ->	 do_printdefault (with call tree below)
+ *
+ *  auto-printing   ->  PrintValueEnv
+ *                      -> PrintValueRec
+ *                      -> call print() for objects
+ *  Note that auto-printing does not call print.default.
+ *  PrintValue, R_PV are similar to auto-printing.
+ *
+ *  do_printdefault
+ *	-> PrintDefaults
+ *	-> CustomPrintValue
+ *	    -> PrintValueRec
+ *		-> __ITSELF__  (recursion)
+ *		-> PrintGenericVector	-> PrintValueRec  (recursion)
+ *		-> printList		-> PrintValueRec  (recursion)
+ *		-> printAttributes	-> PrintValueRec  (recursion)
+ *		-> PrintExpression
+ *		-> printVector		>>>>> ./printvector.c
+ *		-> printNamedVector	>>>>> ./printvector.c
+ *		-> printMatrix		>>>>> ./printarray.c
+ *		-> printArray		>>>>> ./printarray.c
+ *
+ *  do_prmatrix
+ *	-> PrintDefaults
+ *	-> printMatrix			>>>>> ./printarray.c
+ *
+ *
+ *  See ./printutils.c	 for general remarks on Printing
+ *			 and the Encode.. utils.
+ *
+ *  Also ./printvector.c,  ./printarray.c
+ *
+ *  do_sink moved to connections.c as of 1.3.0
+ *
+ *  <FIXME> These routines are not re-entrant: they reset the
+ *  global R_print.
+ *  </FIXME>
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "rffiutils.h"
+#include "Defn.h"
+
+#include "Print.h"
+
+
+/* Global print parameter struct: */
+R_print_par_t R_print;
+
+static void printAttributes(SEXP, SEXP, Rboolean);
+static void PrintSpecial(SEXP);
+static void PrintLanguageEtc(SEXP, Rboolean, Rboolean);
+
+
+#define TAGBUFLEN 256
+#define TAGBUFLEN0 TAGBUFLEN + 6
+static char tagbuf[TAGBUFLEN0];
+
+
+/* Used in X11 module for dataentry */
+/* NB this is called by R.app even though it is in no public header, so
+   alter there if you alter this */
+void PrintDefaults(void)
+{
+    R_print.na_string = NA_STRING;
+    R_print.na_string_noquote = mkChar("<NA>");
+    R_print.na_width = (int) strlen(CHAR(R_print.na_string));
+    R_print.na_width_noquote = (int) strlen(CHAR(R_print.na_string_noquote));
+    R_print.quote = 1;
+    R_print.right = 0; // FastR: modified from Rprt_adj_left;
+    R_print.digits = GetOptionDigits();
+    R_print.scipen = asInteger(GetOption1(install("scipen")));
+    if (R_print.scipen == NA_INTEGER) R_print.scipen = 0;
+    R_print.max = asInteger(GetOption1(install("max.print")));
+    if (R_print.max == NA_INTEGER || R_print.max < 0) R_print.max = 99999;
+    else if(R_print.max == INT_MAX) R_print.max--; // so we can add
+    R_print.gap = 1;
+    R_print.width = GetOptionWidth();
+    R_print.useSource = 0; // FastR: modified from USESOURCE;
+    R_print.cutoff = GetOptionCutoff();
+}
+
+// FastR: the rest of the file is omitted
diff --git a/com.oracle.truffle.r.native/fficall/jni/src/main_sort.c b/com.oracle.truffle.r.native/fficall/jni/src/main_sort.c
new file mode 100644
index 0000000000000000000000000000000000000000..0b07d6869bf59e59d9860746111a6da44647f8d4
--- /dev/null
+++ b/com.oracle.truffle.r.native/fficall/jni/src/main_sort.c
@@ -0,0 +1,28 @@
+/*
+ * 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.
+ */
+
+#define attribute_hidden
+
+#include "Defn.h"
+
+#include "../../../gnur/R-3.1.3/src/main/sort.c"
diff --git a/com.oracle.truffle.r.native/fficall/jni/src/misc.c b/com.oracle.truffle.r.native/fficall/jni/src/misc.c
index 7c7dfaf7dfc18fb1c285d9ddd78198b0959c01b2..d3f42926195ec8b0943db3aca9c8991ff7b4417b 100644
--- a/com.oracle.truffle.r.native/fficall/jni/src/misc.c
+++ b/com.oracle.truffle.r.native/fficall/jni/src/misc.c
@@ -55,14 +55,6 @@ const char *R_CHAR(SEXP string) {
 	return copyChars;
 }
 
-void R_isort(int *x, int n) {
-	unimplemented("R_isort");
-}
-
-void R_rsort(double *x, int n) {
-	unimplemented("R_rsort");
-}
-
 void R_qsort_I  (double *v, int *II, int i, int j) {
 	unimplemented("R_qsort_I");
 }
@@ -71,14 +63,6 @@ void R_qsort_int_I(int *iv, int *II, int i, int j) {
 	unimplemented("R_qsort_int_I");
 }
 
-void rsort_with_index(double *a, int *b, int c) {
-	unimplemented("rsort_with_index");
-}
-
-void revsort(double *a, int *b, int c) {
-	unimplemented("revsort");
-}
-
 void R_CheckUserInterrupt() {
 // TODO (we don't even do this in the Java code)
 }
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
index e700e856d11f11563d345f59d07b1d728399d2a2..8486b64ef766668cea1bfbe7b2eefa0aa1798a21 100644
--- a/com.oracle.truffle.r.native/fficall/jni/src/rf_functions.c
+++ b/com.oracle.truffle.r.native/fficall/jni/src/rf_functions.c
@@ -130,6 +130,7 @@ SEXP Rf_allocMatrix(SEXPTYPE mode, int nrow, int ncol) {
 
 SEXP Rf_allocList(int x) {
 	unimplemented("Rf_allocList)");
+	return NULL;
 }
 
 SEXP Rf_cons(SEXP car, SEXP cdr) {
@@ -145,11 +146,13 @@ void Rf_defineVar(SEXP symbol, SEXP value, SEXP rho) {
 
 SEXP Rf_eval(SEXP expr, SEXP env) {
 	unimplemented("Rf_eval)");
+	return NULL;
 }
 
 SEXP Rf_findFun(SEXP symbol, SEXP rho) {
 	JNIEnv *thisenv = getEnv();
 	unimplemented("Rf_eval)");
+	return NULL;
 }
 
 SEXP Rf_findVar(SEXP symbol, SEXP rho) {
@@ -184,10 +187,12 @@ SEXP Rf_duplicate(SEXP x) {
 
 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;
 }
 
 Rboolean Rf_inherits(SEXP x, const char * klass) {
@@ -197,18 +202,22 @@ Rboolean Rf_inherits(SEXP x, const char * klass) {
 
 Rboolean Rf_isReal(SEXP x) {
     unimplemented("Rf_isReal");
+	return FALSE;
 }
 
 Rboolean Rf_isSymbol(SEXP x) {
     unimplemented("Rf_isSymbol");
+	return FALSE;
 }
 
 Rboolean Rf_isComplex(SEXP s) {
 	unimplemented("Rf_isComplex");
+	return FALSE;
 }
 
 Rboolean Rf_isEnvironment(SEXP s) {
 	unimplemented("Rf_isEnvironment");
+	return FALSE;
 }
 
 Rboolean Rf_isExpression(SEXP x) {
@@ -245,6 +254,7 @@ Rboolean Rf_isString(SEXP s) {
 
 cetype_t Rf_getCharCE(SEXP x) {
 	unimplemented("Rf_getCharCE");
+	return CE_NATIVE;
 }
 
 SEXP Rf_mkChar(const char *x) {
@@ -256,6 +266,7 @@ SEXP Rf_mkChar(const char *x) {
 
 SEXP Rf_mkCharCE(const char *x, cetype_t y) {
 	unimplemented("Rf_mkCharCE");
+	return NULL;
 }
 
 SEXP Rf_mkCharLenCE(const char *x, int len, cetype_t enc) {
@@ -276,10 +287,12 @@ SEXP Rf_mkString(const char *s) {
 
 int Rf_ncols(SEXP x) {
 	unimplemented("Rf_ncols");
+	return 0;
 }
 
 int Rf_nrows(SEXP x) {
 	unimplemented("Rf_nrows");
+	return 0;
 }
 
 
@@ -379,43 +392,33 @@ SEXP R_NewHashedEnv(SEXP parent, SEXP size) {
 	return checkRef(thisenv, result);
 }
 
-void Rf_iPsort(int *x, int n, int k)
-{
-	JNIEnv *thisenv = getEnv();
-	unimplemented("Rf_iPsort");
-}
-
-void Rf_rPsort(double *x, int n, int k) {
-	JNIEnv *thisenv = getEnv();
-	unimplemented("Rf_rPsort");
-}
-
-void Rf_cPsort(Rcomplex *x, int n, int k) {
-	JNIEnv *thisenv = getEnv();
-	unimplemented("Rf_cPsort");
-}
-
 SEXP Rf_classgets(SEXP x, SEXP y) {
 	unimplemented("Rf_classgets");
+	return NULL;
 }
 
 const char *Rf_translateChar(SEXP x) {
 	unimplemented("Rf_translateChar");
+	return NULL;
 }
 
 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 NULL;
 }
 
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 cb295e7195f6161846723be3f0486d9750e2fa61..6d5025eef1162d89fd011def1e4781c00589ec9b 100644
--- a/com.oracle.truffle.r.native/fficall/jni/src/rffiutils.h
+++ b/com.oracle.truffle.r.native/fficall/jni/src/rffiutils.h
@@ -24,6 +24,9 @@
 #define RFFIUTILS_H
 
 #include <jni.h>
+#include <stdlib.h>
+#include <string.h>
+#include <limits.h>
 #include <Rinternals.h>
 #include <setjmp.h>
 
diff --git a/com.oracle.truffle.r.native/fficall/jni/src/typecoerce.c b/com.oracle.truffle.r.native/fficall/jni/src/typecoerce.c
index ce0dd39c562cbddfcef5a7c22b1243aa640b154a..5196081a3cc51a7e548331fbd3b655f816576c8d 100644
--- a/com.oracle.truffle.r.native/fficall/jni/src/typecoerce.c
+++ b/com.oracle.truffle.r.native/fficall/jni/src/typecoerce.c
@@ -45,6 +45,7 @@ SEXP Rf_asChar(SEXP x){
 
 SEXP Rf_coerceVector(SEXP x, SEXPTYPE t){
 	unimplemented("Rf_coerceVector");
+	return NULL;
 }
 
 SEXP Rf_PairToVectorList(SEXP x){
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 dd7340fd544d9cfc436717f8fd26c5eb3bdfaad0..b6c658a4777dac277a3c068eefa6e7aee497fd9e 100644
--- a/com.oracle.truffle.r.native/fficall/jni/src/variables.c
+++ b/com.oracle.truffle.r.native/fficall/jni/src/variables.c
@@ -90,11 +90,19 @@ int	 R_NaInt;	/* NA_INTEGER:= INT_MIN currently */
 // from Defn.h
 const char* R_Home;
 const char* R_TempDir;
-Rboolean R_Visible; // ignored
-Rboolean R_interrupts_suspended; // ignored
-int R_interrupts_pending; // ignored
-Rboolean mbcslocale; // ignored
-Rboolean useaqua; // ignored
+
+// 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;
 
 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
index 235f6af1ef63c72f5a595cda7818bdfbbba6aea8..723e3ba7d603c8730f95aee55d265638c18226d9 100644
--- a/com.oracle.truffle.r.native/fficall/jni/src/vectoraccess.c
+++ b/com.oracle.truffle.r.native/fficall/jni/src/vectoraccess.c
@@ -133,7 +133,7 @@ Rbyte *RAW(SEXP x){
 	    data = (*thisenv)->GetByteArrayElements(thisenv, byteArray, NULL);
         addCopiedObject(thisenv, x, RAWSXP, byteArray, data);
     }
-	return data;
+	return (Rbyte*) data;
 }
 
 
diff --git a/com.oracle.truffle.r.runtime.ffi/src/com/oracle/truffle/r/runtime/ffi/jnr/CallRFFIWithJNI.java b/com.oracle.truffle.r.runtime.ffi/src/com/oracle/truffle/r/runtime/ffi/jnr/CallRFFIWithJNI.java
index 7bb9ce2a1f665f61289a7e4581aa41dce8b1a67d..8767a407b67cb8d304eb147cb9e8f9900dc21990 100644
--- a/com.oracle.truffle.r.runtime.ffi/src/com/oracle/truffle/r/runtime/ffi/jnr/CallRFFIWithJNI.java
+++ b/com.oracle.truffle.r.runtime.ffi/src/com/oracle/truffle/r/runtime/ffi/jnr/CallRFFIWithJNI.java
@@ -30,6 +30,7 @@ import com.oracle.truffle.r.runtime.REnvVars;
 import com.oracle.truffle.r.runtime.RError;
 import com.oracle.truffle.r.runtime.RInternalError;
 import com.oracle.truffle.r.runtime.RRuntime;
+import com.oracle.truffle.r.runtime.context.RContext;
 import com.oracle.truffle.r.runtime.data.RDataFactory;
 import com.oracle.truffle.r.runtime.data.RMissing;
 import com.oracle.truffle.r.runtime.data.RNull;
@@ -130,7 +131,11 @@ public class CallRFFIWithJNI implements CallRFFI {
         try {
             DLL.load(librffiPath, ForceRTLDGlobal, false);
         } catch (DLLException ex) {
-            throw RError.error(RError.NO_NODE, ex);
+            if (RContext.getRRuntimeASTAccess() != null) {
+                throw RError.error(RError.NO_NODE, ex);
+            } else {
+                throw new RInternalError(ex, "error while loading " + librffiPath);
+            }
         }
         System.load(librffiPath);
         initialize(RVariables.values());
diff --git a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/RError.java b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/RError.java
index b21c24f163ecefb467b388fdac4d6a426a0644e7..69fe2d554f6ae686f6e031e88e5282f9dc20bcab 100644
--- a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/RError.java
+++ b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/RError.java
@@ -63,12 +63,6 @@ public final class RError extends RuntimeException {
             this.msg = msg;
             this.args = args;
         }
-
-        @SuppressWarnings("sync-override")
-        @Override
-        public Throwable fillInStackTrace() {
-            return null;
-        }
     }
 
     /**
diff --git a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/Utils.java b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/Utils.java
index 30a48a80f2562c939f5f96d2a249324cdfeb7526..9e47a2e4945188cdd38791251fb120c8ec00af2e 100644
--- a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/Utils.java
+++ b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/Utils.java
@@ -130,7 +130,11 @@ public final class Utils {
         if (RContext.getInstance().getOptions().getString(RCmdOption.DEBUGGER) != null) {
             throw new DebugExitException();
         } else {
-            RContext.getInstance().destroy();
+            try {
+                RContext.getInstance().destroy();
+            } catch (Throwable t) {
+                // ignore
+            }
             System.exit(status);
             return null;
         }