diff --git a/.hgignore b/.hgignore
index e52c83ba9b3dbf668bd5737330e18df1c99d149d..1b9895009042e8ac7b65095a1dd1f60f07cb59f1 100644
--- a/.hgignore
+++ b/.hgignore
@@ -13,6 +13,8 @@
 ^com.oracle.truffle.r.test/rpackages/testrlibs_user
 ^com.oracle.truffle.r.test.native/urand/lib/liburand.so
 ^com.oracle.truffle.r.native/gnur/R-*
+com.oracle.truffle.r.native/fficall/src/jni/arithmetic.c
+com.oracle.truffle.r.native/fficall/src/jni/util.c
 ^DEPARSE_ERROR
 ^Rpkgsource/*
 ^install.cran.logs/
diff --git a/com.oracle.truffle.r.native/fficall/Makefile b/com.oracle.truffle.r.native/fficall/Makefile
index c5ae2b2bb64a616e315bf37c7d6ad74b7c7834f4..50f72a62228a24596389e1eea4e753f1fc2dc03d 100644
--- a/com.oracle.truffle.r.native/fficall/Makefile
+++ b/com.oracle.truffle.r.native/fficall/Makefile
@@ -24,7 +24,8 @@
 .PHONY: all clean
 
 all:
-	$(MAKE) -C jni
+	$(MAKE) -C src/jni links
+	$(MAKE) -C src/jni all
 
 clean:
-	$(MAKE) -C jni clean
+	$(MAKE) -C src/jni clean
diff --git a/com.oracle.truffle.r.native/fficall/common/src/arithmetic.c b/com.oracle.truffle.r.native/fficall/src/common/arithmetic.c
similarity index 100%
rename from com.oracle.truffle.r.native/fficall/common/src/arithmetic.c
rename to com.oracle.truffle.r.native/fficall/src/common/arithmetic.c
diff --git a/com.oracle.truffle.r.native/fficall/common/src/util.c b/com.oracle.truffle.r.native/fficall/src/common/util.c
similarity index 100%
rename from com.oracle.truffle.r.native/fficall/common/src/util.c
rename to com.oracle.truffle.r.native/fficall/src/common/util.c
diff --git a/com.oracle.truffle.r.native/fficall/common/src/variable_defs.h b/com.oracle.truffle.r.native/fficall/src/common/variable_defs.h
similarity index 100%
rename from com.oracle.truffle.r.native/fficall/common/src/variable_defs.h
rename to com.oracle.truffle.r.native/fficall/src/common/variable_defs.h
diff --git a/com.oracle.truffle.r.native/fficall/jni/src/Applic.c b/com.oracle.truffle.r.native/fficall/src/jni/Applic.c
similarity index 100%
rename from com.oracle.truffle.r.native/fficall/jni/src/Applic.c
rename to com.oracle.truffle.r.native/fficall/src/jni/Applic.c
diff --git a/com.oracle.truffle.r.native/fficall/jni/src/Connections.c b/com.oracle.truffle.r.native/fficall/src/jni/Connections.c
similarity index 100%
rename from com.oracle.truffle.r.native/fficall/jni/src/Connections.c
rename to com.oracle.truffle.r.native/fficall/src/jni/Connections.c
diff --git a/com.oracle.truffle.r.native/fficall/jni/src/Defn.h b/com.oracle.truffle.r.native/fficall/src/jni/Defn.h
similarity index 100%
rename from com.oracle.truffle.r.native/fficall/jni/src/Defn.h
rename to com.oracle.truffle.r.native/fficall/src/jni/Defn.h
diff --git a/com.oracle.truffle.r.native/fficall/jni/Makefile b/com.oracle.truffle.r.native/fficall/src/jni/Makefile
similarity index 66%
rename from com.oracle.truffle.r.native/fficall/jni/Makefile
rename to com.oracle.truffle.r.native/fficall/src/jni/Makefile
index 4d3e358b0a5327b3b5d971cc75821103ddeb43f9..5787de86b09cb1d92cd69e9e5ccdf2e6bea8ab50 100644
--- a/com.oracle.truffle.r.native/fficall/jni/Makefile
+++ b/com.oracle.truffle.r.native/fficall/src/jni/Makefile
@@ -22,40 +22,42 @@
 #
 
 ifeq ($(TOPDIR),)
-    TOPDIR = $(abspath ../..)
+    TOPDIR = $(abspath ../../..)
 endif
 
 ifneq ($(MAKECMDGOALS),clean)
 include $(TOPDIR)/platform.mk
 endif
 
-.PHONY: all clean common_links
+.PHONY: all clean links
 
-OBJ = ../lib
-SRC = src
-C_LOCAL_SOURCES := $(wildcard $(SRC)/*.c)
-C_HDRS := $(wildcard $(SRC)/*.h)
-C_LIBNAME := librfficall$(DYLIB_EXT)
-C_LIB := $(TOPDIR)/../lib/$(C_LIBNAME)
+OBJ = ../../lib
 
 COMMON = ../common
-C_COMMON_SOURCES := $(notdir $(wildcard $(COMMON)/src/*.c))
+C_COMMON_SOURCES := $(notdir $(wildcard $(COMMON)/*.c))
+#$(info C_COMMON_SOURCE=$(C_COMMON_SOURCES))
+
+# if link was already set, C_COMMON_SOURCES will be included twice without following filter
+C_LOCAL_SOURCES := $(filter-out  $(C_COMMON_SOURCES),$(wildcard *.c))
+#$(info C_LOCAL_SOURCES=$(C_LOCAL_SOURCES))
+C_HDRS := $(wildcard *.h)
+C_LIBNAME := librfficall$(DYLIB_EXT)
+C_LIB := $(TOPDIR)/../lib/$(C_LIBNAME)
 
-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))
+C_SOURCES = $(C_LOCAL_SOURCES) $(C_COMMON_SOURCES)
+#$(info C_SOURCES=$(C_SOURCES))
+C_OBJECTS := $(patsubst %.c,$(OBJ)/%.o,$(C_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: Makefile common_links $(C_LIB) 
+all: Makefile $(C_COMMON_SOURCES) $(C_LIB) 
 
-common_links:
-	$(foreach file,$(C_COMMON_SOURCES),ln -sf ../$(COMMON)/$(file) $(SRC)/$(file);)	
+links:
+	$(foreach file,$(C_COMMON_SOURCES),ln -sf $(COMMON)/$(file) $(file);)	
 
 $(C_LIB): $(OBJ) $(C_OBJECTS)
 	$(DYLIB_LD) $(DYLIB_LDFLAGS) -o $(C_LIB) $(C_OBJECTS)
@@ -63,12 +65,12 @@ $(C_LIB): $(OBJ) $(C_OBJECTS)
 $(OBJ):
 	mkdir -p $(OBJ)
 
-$(OBJ)/%.o: $(SRC)/%.c $(TOPDIR)/include/Rinternals.h $(C_HDRS)
+$(OBJ)/%.o: %.c $(TOPDIR)/include/Rinternals.h $(C_HDRS)
 	$(CC) $(CFLAGS) $(INCLUDES) -c $< -o $@
 	
-$(OBJ)/%.E: $(SRC)/%.c $(TOPDIR)/include/Rinternals.h
+$(OBJ)/%.E: %.c $(TOPDIR)/include/Rinternals.h
 	$(CC) -E $(CFLAGS) $(INCLUDES) -c $< > $@
 
 clean:
 	rm -rf $(OBJ) $(C_LIB)
-	$(foreach file,$(C_COMMON_SOURCES),rm -f $(SRC)/$(file);)	
+	$(foreach file,$(C_COMMON_SOURCES),rm -f $(file);)	
diff --git a/com.oracle.truffle.r.native/fficall/jni/src/Memory.c b/com.oracle.truffle.r.native/fficall/src/jni/Memory.c
similarity index 100%
rename from com.oracle.truffle.r.native/fficall/jni/src/Memory.c
rename to com.oracle.truffle.r.native/fficall/src/jni/Memory.c
diff --git a/com.oracle.truffle.r.native/fficall/jni/src/Parse.c b/com.oracle.truffle.r.native/fficall/src/jni/Parse.c
similarity index 100%
rename from com.oracle.truffle.r.native/fficall/jni/src/Parse.c
rename to com.oracle.truffle.r.native/fficall/src/jni/Parse.c
diff --git a/com.oracle.truffle.r.native/fficall/jni/src/Random.c b/com.oracle.truffle.r.native/fficall/src/jni/Random.c
similarity index 100%
rename from com.oracle.truffle.r.native/fficall/jni/src/Random.c
rename to com.oracle.truffle.r.native/fficall/src/jni/Random.c
diff --git a/com.oracle.truffle.r.native/fficall/jni/src/Rdynload.c b/com.oracle.truffle.r.native/fficall/src/jni/Rdynload.c
similarity index 100%
rename from com.oracle.truffle.r.native/fficall/jni/src/Rdynload.c
rename to com.oracle.truffle.r.native/fficall/src/jni/Rdynload.c
diff --git a/com.oracle.truffle.r.native/fficall/jni/src/Rinternals.c b/com.oracle.truffle.r.native/fficall/src/jni/Rinternals.c
similarity index 100%
rename from com.oracle.truffle.r.native/fficall/jni/src/Rinternals.c
rename to com.oracle.truffle.r.native/fficall/src/jni/Rinternals.c
diff --git a/com.oracle.truffle.r.native/fficall/jni/src/Rmath.c b/com.oracle.truffle.r.native/fficall/src/jni/Rmath.c
similarity index 100%
rename from com.oracle.truffle.r.native/fficall/jni/src/Rmath.c
rename to com.oracle.truffle.r.native/fficall/src/jni/Rmath.c
diff --git a/com.oracle.truffle.r.native/fficall/jni/src/Utils.c b/com.oracle.truffle.r.native/fficall/src/jni/Utils.c
similarity index 100%
rename from com.oracle.truffle.r.native/fficall/jni/src/Utils.c
rename to com.oracle.truffle.r.native/fficall/src/jni/Utils.c
diff --git a/com.oracle.truffle.r.native/fficall/jni/src/appl_pretty.c b/com.oracle.truffle.r.native/fficall/src/jni/appl_pretty.c
similarity index 100%
rename from com.oracle.truffle.r.native/fficall/jni/src/appl_pretty.c
rename to com.oracle.truffle.r.native/fficall/src/jni/appl_pretty.c
diff --git a/com.oracle.truffle.r.native/fficall/jni/src/coerce.c b/com.oracle.truffle.r.native/fficall/src/jni/coerce.c
similarity index 100%
rename from com.oracle.truffle.r.native/fficall/jni/src/coerce.c
rename to com.oracle.truffle.r.native/fficall/src/jni/coerce.c
diff --git a/com.oracle.truffle.r.native/fficall/jni/src/inlined.c b/com.oracle.truffle.r.native/fficall/src/jni/inlined.c
similarity index 100%
rename from com.oracle.truffle.r.native/fficall/jni/src/inlined.c
rename to com.oracle.truffle.r.native/fficall/src/jni/inlined.c
diff --git a/com.oracle.truffle.r.native/fficall/jni/src/main_colors.c b/com.oracle.truffle.r.native/fficall/src/jni/main_colors.c
similarity index 100%
rename from com.oracle.truffle.r.native/fficall/jni/src/main_colors.c
rename to com.oracle.truffle.r.native/fficall/src/jni/main_colors.c
diff --git a/com.oracle.truffle.r.native/fficall/jni/src/main_devices.c b/com.oracle.truffle.r.native/fficall/src/jni/main_devices.c
similarity index 100%
rename from com.oracle.truffle.r.native/fficall/jni/src/main_devices.c
rename to com.oracle.truffle.r.native/fficall/src/jni/main_devices.c
diff --git a/com.oracle.truffle.r.native/fficall/jni/src/main_engine.c b/com.oracle.truffle.r.native/fficall/src/jni/main_engine.c
similarity index 100%
rename from com.oracle.truffle.r.native/fficall/jni/src/main_engine.c
rename to com.oracle.truffle.r.native/fficall/src/jni/main_engine.c
diff --git a/com.oracle.truffle.r.native/fficall/jni/src/main_format.c b/com.oracle.truffle.r.native/fficall/src/jni/main_format.c
similarity index 100%
rename from com.oracle.truffle.r.native/fficall/jni/src/main_format.c
rename to com.oracle.truffle.r.native/fficall/src/jni/main_format.c
diff --git a/com.oracle.truffle.r.native/fficall/jni/src/main_graphics.c b/com.oracle.truffle.r.native/fficall/src/jni/main_graphics.c
similarity index 100%
rename from com.oracle.truffle.r.native/fficall/jni/src/main_graphics.c
rename to com.oracle.truffle.r.native/fficall/src/jni/main_graphics.c
diff --git a/com.oracle.truffle.r.native/fficall/jni/src/main_plot.c b/com.oracle.truffle.r.native/fficall/src/jni/main_plot.c
similarity index 100%
rename from com.oracle.truffle.r.native/fficall/jni/src/main_plot.c
rename to com.oracle.truffle.r.native/fficall/src/jni/main_plot.c
diff --git a/com.oracle.truffle.r.native/fficall/jni/src/main_plot3d.c b/com.oracle.truffle.r.native/fficall/src/jni/main_plot3d.c
similarity index 100%
rename from com.oracle.truffle.r.native/fficall/jni/src/main_plot3d.c
rename to com.oracle.truffle.r.native/fficall/src/jni/main_plot3d.c
diff --git a/com.oracle.truffle.r.native/fficall/jni/src/main_plotmath.c b/com.oracle.truffle.r.native/fficall/src/jni/main_plotmath.c
similarity index 100%
rename from com.oracle.truffle.r.native/fficall/jni/src/main_plotmath.c
rename to com.oracle.truffle.r.native/fficall/src/jni/main_plotmath.c
diff --git a/com.oracle.truffle.r.native/fficall/jni/src/main_print.c b/com.oracle.truffle.r.native/fficall/src/jni/main_print.c
similarity index 100%
rename from com.oracle.truffle.r.native/fficall/jni/src/main_print.c
rename to com.oracle.truffle.r.native/fficall/src/jni/main_print.c
diff --git a/com.oracle.truffle.r.native/fficall/jni/src/main_rlocale.c b/com.oracle.truffle.r.native/fficall/src/jni/main_rlocale.c
similarity index 100%
rename from com.oracle.truffle.r.native/fficall/jni/src/main_rlocale.c
rename to com.oracle.truffle.r.native/fficall/src/jni/main_rlocale.c
diff --git a/com.oracle.truffle.r.native/fficall/jni/src/main_sort.c b/com.oracle.truffle.r.native/fficall/src/jni/main_sort.c
similarity index 100%
rename from com.oracle.truffle.r.native/fficall/jni/src/main_sort.c
rename to com.oracle.truffle.r.native/fficall/src/jni/main_sort.c
diff --git a/com.oracle.truffle.r.native/fficall/jni/src/rfficall.c b/com.oracle.truffle.r.native/fficall/src/jni/rfficall.c
similarity index 100%
rename from com.oracle.truffle.r.native/fficall/jni/src/rfficall.c
rename to com.oracle.truffle.r.native/fficall/src/jni/rfficall.c
diff --git a/com.oracle.truffle.r.native/fficall/jni/src/rffiutils.c b/com.oracle.truffle.r.native/fficall/src/jni/rffiutils.c
similarity index 100%
rename from com.oracle.truffle.r.native/fficall/jni/src/rffiutils.c
rename to com.oracle.truffle.r.native/fficall/src/jni/rffiutils.c
diff --git a/com.oracle.truffle.r.native/fficall/jni/src/rffiutils.h b/com.oracle.truffle.r.native/fficall/src/jni/rffiutils.h
similarity index 100%
rename from com.oracle.truffle.r.native/fficall/jni/src/rffiutils.h
rename to com.oracle.truffle.r.native/fficall/src/jni/rffiutils.h
diff --git a/com.oracle.truffle.r.native/fficall/jni/src/sys.c b/com.oracle.truffle.r.native/fficall/src/jni/sys.c
similarity index 100%
rename from com.oracle.truffle.r.native/fficall/jni/src/sys.c
rename to com.oracle.truffle.r.native/fficall/src/jni/sys.c
diff --git a/com.oracle.truffle.r.native/fficall/jni/src/unimplemented.c b/com.oracle.truffle.r.native/fficall/src/jni/unimplemented.c
similarity index 100%
rename from com.oracle.truffle.r.native/fficall/jni/src/unimplemented.c
rename to com.oracle.truffle.r.native/fficall/src/jni/unimplemented.c
diff --git a/com.oracle.truffle.r.native/fficall/jni/src/variables.c b/com.oracle.truffle.r.native/fficall/src/jni/variables.c
similarity index 99%
rename from com.oracle.truffle.r.native/fficall/jni/src/variables.c
rename to com.oracle.truffle.r.native/fficall/src/jni/variables.c
index f3e04dad94ef14375d70813c6c07a168d731307d..971a8c8802fe0032ac88761d39a3378cf4440dbb 100644
--- a/com.oracle.truffle.r.native/fficall/jni/src/variables.c
+++ b/com.oracle.truffle.r.native/fficall/src/jni/variables.c
@@ -29,7 +29,7 @@
 #include <jni.h>
 #include <Rinternals.h>
 #include "rffiutils.h"
-#include "../../common/src/variable_defs.h"
+#include "../common/variable_defs.h"
 
 jmethodID getGlobalEnvMethodID;
 jmethodID getBaseEnvMethodID;