diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/function/FunctionDefinitionNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/function/FunctionDefinitionNode.java
index e2019c4c78506fca390f3b711385e08ee8b1d999..e80fd443b5553b2a7f63ca0e893a86343d39aa87 100644
--- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/function/FunctionDefinitionNode.java
+++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/function/FunctionDefinitionNode.java
@@ -93,7 +93,7 @@ public final class FunctionDefinitionNode extends RRootNode implements RSyntaxNo
     private String name;
     private boolean instrumented = false;
     private SourceSection sourceSectionR;
-    private final SourceSection[] argSourceSections;
+    public final SourceSection[] argSourceSections;
 
     @Child private RNode saveArguments;
     @Child private FrameSlotNode onExitSlot;
diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/qirinterface/QIRInterface.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/qirinterface/QIRInterface.java
index 8011336fce314a997c0d394633a4c7c3a4df479b..21f128cd563f60f1dc14e0938f031c73d150e129 100644
--- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/qirinterface/QIRInterface.java
+++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/qirinterface/QIRInterface.java
@@ -27,6 +27,7 @@ import java.io.IOException;
 import java.io.Reader;
 import java.math.BigInteger;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Properties;
@@ -41,6 +42,7 @@ import com.oracle.truffle.r.runtime.RRuntime;
 import com.oracle.truffle.r.runtime.context.RContext;
 import com.oracle.truffle.r.runtime.data.RFunction;
 import com.oracle.truffle.r.runtime.env.REnvironment;
+
 import qir.ast.*;
 import qir.ast.data.*;
 import qir.ast.value.*;
@@ -93,7 +95,6 @@ public final class QIRInterface {
             for (final QIRVariable fv : fvs.values()) {
                 final String varName = fv.getId();
                 final FrameSlot varSlot = frame.getFrameDescriptor().findFrameSlot(varName);
-                // TODO: Handle functions other than builtins
                 query = new QIRApply(dummy, new QIRLambda(dummy, null, new QIRVariable(dummy, varName, varSlot), query),
                                 RToQIRType(fv.sourceSection, varSlot != null ? frame.getValue(varSlot) : RContext.lookupBuiltin(varName)));
             }
@@ -232,16 +233,33 @@ public final class QIRInterface {
                 tuple = new QIRTcons(src, (String) x, RToQIRType(src, env.get((String) x)), tuple);
             return tuple;
         }
-        if (value instanceof RFunction && ((RFunction) value).isBuiltin()) {
-            switch (((RFunction) value).getName()) {
-                case "new.env":
-                    return new QIRLambda(null, "new.env", new QIRVariable(null, "_", null), QIRTnil.getInstance());
-                case "return":
-                case "(":
-                    final QIRVariable x = new QIRVariable(null, "x", null);
-                    return new QIRLambda(null, "identity", x, x);
-                default:
-                    throw new RuntimeException("Unsupported value: " + value + " : " + value.getClass());
+        if (value instanceof RFunction) {
+            final RFunction fun = (RFunction) value;
+            if (fun.isBuiltin())
+                switch (fun.getName()) {
+                    case "new.env":
+                        return new QIRLambda(null, "new.env", new QIRVariable(null, "_", null), QIRTnil.getInstance());
+                    case "return":
+                    case "(":
+                        final QIRVariable x = new QIRVariable(null, "x", null);
+                        return new QIRLambda(null, "identity", x, x);
+                    default:
+                        throw new RuntimeException("Unsupported value: " + value + " : " + value.getClass());
+                }
+            try {
+                final FunctionDefinitionNode rootNode = (FunctionDefinitionNode) fun.getRootNode();
+                QIRNode res = rootNode.getBody().accept(QIRTranslateVisitor.instance);
+                final String[] args = Arrays.asList(rootNode.argSourceSections).stream().map(arg -> arg.getCode()).toArray(size -> new String[size]);
+                final String funName = fun.getName();
+                if (args.length == 0)
+                    return new QIRLambda(src, funName, null, res);
+                for (int i = 0; i < args.length; i++)
+                    res = new QIRLambda(src, funName, new QIRVariable(null, args[i], null), res);
+                return res;
+            } catch (UnsupportedOperationException e) {
+                final SourceSection funSrc = fun.getRootNode().getSourceSection();
+                // TODO: Handle dependencies
+                return new QIRTruffleNode(funSrc, funSrc.getCode());
             }
         }
         throw new RuntimeException("Unsupported value: " + value);