diff --git a/mx.fastr/mx_fastr_dists.py b/mx.fastr/mx_fastr_dists.py
index c6ee9c06ebfa3ce81a1d25c53d12c3e2d7439be4..303f1569cdf10b56fc9e0a17cfb34bd928e1952c 100644
--- a/mx.fastr/mx_fastr_dists.py
+++ b/mx.fastr/mx_fastr_dists.py
@@ -91,7 +91,7 @@ class DelFastRNativeProject(FastRProjectAdapter):
         gnur_tools_src = join(gnur, 'src', 'library', 'tools', 'src')
         for f in ['gramRd.c', 'init.c', 'tools.h']:
             results.append(join(self.dir, gnur_tools_src, f))
-        for f in ['lib.mk', 'Makefile', 'tools/src/tools_dummy.c', 'tools/Makefile']:
+        for f in ['lib.mk', 'Makefile', 'tools/src/tools_dummy.c', 'tools/src/gramRd_fastr.h', 'tools/Makefile']:
             results.append(join(self.dir, 'library', f))
 
         # selected headers from GNU R source
diff --git a/mx.fastr/mx_fastr_mkgramrd.py b/mx.fastr/mx_fastr_mkgramrd.py
index fdbfebbbb8a78f2017d64e2c063698a17722b699..fba187ff0e7a17932f3e6ee4d108195c44f444d5 100644
--- a/mx.fastr/mx_fastr_mkgramrd.py
+++ b/mx.fastr/mx_fastr_mkgramrd.py
@@ -56,15 +56,6 @@ static int Rconn_fgetc(Rconnection con) {
     return -1;
 }
 
-extern JNIEnv *getEnv();
-static jmethodID getcMethodID;
-
-'''
-
-    fastr_getc = '''
-    JNIEnv *env = getEnv();
-    jclass klass = (*env)->FindClass(env, "com/oracle/truffle/r/runtime/conn/RConnection");
-    getcMethodID = (*env)->GetMethodID(env, klass, "getc", "()I");
 '''
 
     c_parserd = '''
@@ -123,17 +114,13 @@ SEXP C_parseRd(SEXP con, SEXP source, SEXP verbose, SEXP fragment, SEXP basename
             elif '#include <Rmath.h>' in sline:
                 line = '//' + line
                 f.write(line)
-                f.write('#include <jni.h>\n')
+                f.write('#include "gramRd_fastr.h"\n')
             elif sline == '#include "Rconnections.h"':
                 line = '//' + line
                 f.write(line)
                 f.write(connect_defs)
             elif 'c = Rconn_fgetc(con_parse);' in sline:
-                f.write('    JNIEnv *env = getEnv();\n')
-                f.write('    c = (*env)->CallIntMethod(env, con_parse, getcMethodID, con_parse);\n')
-            elif 'ptr_getc = con_getc;' in line:
-                f.write(fastr_getc)
-                f.write(line)
+                f.write('    c = callGetCMethod(con_parse);\n')
             elif sline == 'static void con_cleanup(void *data)':
                 # skip
                 i = i + 5