diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/AsVector.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/AsVector.java
index 2711a58673ceff2f0271114a98d7144e3db8f0f7..4f4f891f4fd685a2b110d829d5b910f419ccc618 100644
--- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/AsVector.java
+++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/AsVector.java
@@ -90,7 +90,7 @@ public abstract class AsVector extends RBuiltinNode {
     private RSymbol castSymbol(VirtualFrame frame, Object operand) {
         if (castSymbol == null) {
             CompilerDirectives.transferToInterpreterAndInvalidate();
-            castSymbol = insert(CastSymbolNodeFactory.create(null, false, false, false, false));
+            castSymbol = insert(CastSymbolNodeFactory.create(null, false, false, false));
         }
         return (RSymbol) castSymbol.executeSymbol(frame, operand);
     }
diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastComplexNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastComplexNode.java
index 1bef3d10de5b2e834a31355307ac2cd40637fa6b..1e38b21933e742c4b75757cc2657a260e4b2e44b 100644
--- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastComplexNode.java
+++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastComplexNode.java
@@ -22,9 +22,12 @@
  */
 package com.oracle.truffle.r.nodes.unary;
 
+import java.util.function.*;
+
 import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
 import com.oracle.truffle.api.dsl.*;
 import com.oracle.truffle.api.frame.*;
+import com.oracle.truffle.api.utilities.*;
 import com.oracle.truffle.r.runtime.*;
 import com.oracle.truffle.r.runtime.data.*;
 import com.oracle.truffle.r.runtime.data.model.*;
@@ -33,6 +36,7 @@ import com.oracle.truffle.r.runtime.ops.na.*;
 public abstract class CastComplexNode extends CastNode {
 
     private final NACheck naCheck = NACheck.create();
+    private final BranchProfile warningBranch = BranchProfile.create();
 
     public abstract Object executeComplex(VirtualFrame frame, int o);
 
@@ -80,149 +84,54 @@ public abstract class CastComplexNode extends CastNode {
         naCheck.enable(operand);
         RComplex result = naCheck.convertStringToComplex(operand);
         if (RRuntime.isNA(result)) {
+            warningBranch.enter();
             RError.warning(RError.Message.NA_INTRODUCED_COERCION);
         }
         return result;
     }
 
-    private double[] dataFromLogical(RLogicalVector operand) {
-        naCheck.enable(operand);
-        double[] ddata = new double[operand.getLength() << 1];
-        for (int i = 0; i < operand.getLength(); i++) {
-            byte value = operand.getDataAt(i);
-            RComplex complexValue = naCheck.convertLogicalToComplex(value);
-            int index = i << 1;
-            ddata[index] = complexValue.getRealPart();
-            ddata[index + 1] = complexValue.getImaginaryPart();
-        }
-        return ddata;
-    }
-
-    private double[] dataFromString(RStringVector operand) {
+    private RComplexVector createResultVector(RAbstractVector operand, IntFunction<RComplex> elementFunction) {
         naCheck.enable(operand);
         double[] ddata = new double[operand.getLength() << 1];
         for (int i = 0; i < operand.getLength(); i++) {
-            String value = operand.getDataAt(i);
-            RComplex complexValue = naCheck.convertStringToComplex(value);
-            if (RRuntime.isNA(complexValue)) {
-                RError.warning(RError.Message.NA_INTRODUCED_COERCION);
-            }
+            RComplex complexValue = elementFunction.apply(i);
             int index = i << 1;
             ddata[index] = complexValue.getRealPart();
             ddata[index + 1] = complexValue.getImaginaryPart();
         }
-        return ddata;
-    }
-
-    private static double[] dataFromRaw(RRawVector operand) {
-        double[] ddata = new double[operand.getLength() << 1];
-        for (int i = 0; i < operand.getLength(); i++) {
-            byte value = operand.getDataAt(i).getValue();
-            int index = i << 1;
-            ddata[index] = value;
-            ddata[index + 1] = 0;
-        }
-        return ddata;
-    }
-
-    @Specialization
-    protected RComplexVector doIntVector(RIntVector operand) {
-        return performAbstractIntVector(operand);
-    }
-
-    @Specialization
-    protected RComplexVector doIntSequence(RIntSequence operand) {
-        return performAbstractIntVector(operand);
-    }
-
-    @Specialization(guards = {"!preserveNames", "preserveDimensions"})
-    protected RComplexVector doLogicalVectorDims(RLogicalVector operand) {
-        double[] ddata = dataFromLogical(operand);
-        RComplexVector ret = RDataFactory.createComplexVector(ddata, naCheck.neverSeenNA(), operand.getDimensions());
-        if (isAttrPreservation()) {
-            ret.copyRegAttributesFrom(operand);
-        }
-        return ret;
-    }
-
-    @Specialization(guards = {"preserveNames", "!preserveDimensions"})
-    protected RComplexVector doLogicalVectorNames(RLogicalVector operand) {
-        double[] ddata = dataFromLogical(operand);
-        RComplexVector ret = RDataFactory.createComplexVector(ddata, naCheck.neverSeenNA(), operand.getNames());
-        if (isAttrPreservation()) {
-            ret.copyRegAttributesFrom(operand);
-        }
-        return ret;
-    }
-
-    @Specialization(guards = {"preserveNames", "preserveDimensions"})
-    protected RComplexVector doLogicalVectorDimsNames(RLogicalVector operand) {
-        double[] ddata = dataFromLogical(operand);
-        RComplexVector ret = RDataFactory.createComplexVector(ddata, naCheck.neverSeenNA(), operand.getDimensions(), operand.getNames());
-        if (isAttrPreservation()) {
-            ret.copyRegAttributesFrom(operand);
-        }
-        return ret;
-    }
-
-    @Specialization(guards = {"!preserveNames", "!preserveDimensions"})
-    protected RComplexVector doLogicalVector(RLogicalVector operand) {
-        double[] ddata = dataFromLogical(operand);
-        RComplexVector ret = RDataFactory.createComplexVector(ddata, naCheck.neverSeenNA());
-        if (isAttrPreservation()) {
-            ret.copyRegAttributesFrom(operand);
-        }
-        return ret;
-    }
-
-    @Specialization(guards = {"!preserveNames", "preserveDimensions"})
-    protected RComplexVector doStringVectorDims(RStringVector operand) {
-        double[] ddata = dataFromString(operand);
-        RComplexVector ret = RDataFactory.createComplexVector(ddata, naCheck.neverSeenNA(), operand.getDimensions());
-        if (isAttrPreservation()) {
-            ret.copyRegAttributesFrom(operand);
-        }
-        return ret;
-    }
-
-    @Specialization(guards = {"preserveNames", "!preserveDimensions"})
-    protected RComplexVector doStringVectorNames(RStringVector operand) {
-        double[] ddata = dataFromString(operand);
-        RComplexVector ret = RDataFactory.createComplexVector(ddata, naCheck.neverSeenNA(), operand.getNames());
+        RComplexVector ret = RDataFactory.createComplexVector(ddata, naCheck.neverSeenNA(), isPreserveDimensions() ? operand.getDimensions() : null, isPreserveNames() ? operand.getNames() : null);
         if (isAttrPreservation()) {
             ret.copyRegAttributesFrom(operand);
         }
         return ret;
     }
 
-    @Specialization(guards = {"preserveNames", "preserveDimensions"})
-    protected RComplexVector doStringVectorDimsNames(RStringVector operand) {
-        double[] ddata = dataFromString(operand);
-        RComplexVector ret = RDataFactory.createComplexVector(ddata, naCheck.neverSeenNA(), operand.getDimensions(), operand.getNames());
-        if (isAttrPreservation()) {
-            ret.copyRegAttributesFrom(operand);
-        }
-        return ret;
+    @Specialization
+    protected RComplexVector doIntVector(RAbstractIntVector operand) {
+        return createResultVector(operand, index -> naCheck.convertIntToComplex(operand.getDataAt(index)));
     }
 
-    @Specialization(guards = {"!preserveNames", "!preserveDimensions"})
-    protected RComplexVector doStringVector(RStringVector operand) {
-        double[] ddata = dataFromString(operand);
-        RComplexVector ret = RDataFactory.createComplexVector(ddata, naCheck.neverSeenNA());
-        if (isAttrPreservation()) {
-            ret.copyRegAttributesFrom(operand);
-        }
-        return ret;
+    @Specialization
+    protected RComplexVector doDoubleVector(RAbstractDoubleVector operand) {
+        return createResultVector(operand, index -> naCheck.convertDoubleToComplex(operand.getDataAt(index)));
     }
 
     @Specialization
-    protected RComplexVector doDoubleVector(RDoubleVector operand) {
-        return performAbstractDoubleVector(operand);
+    protected RComplexVector doLogicalVector(RLogicalVector operand) {
+        return createResultVector(operand, index -> naCheck.convertLogicalToComplex(operand.getDataAt(index)));
     }
 
     @Specialization
-    protected RComplexVector doDoubleSequence(RDoubleSequence operand) {
-        return performAbstractDoubleVector(operand);
+    protected RComplexVector doStringVector(RStringVector operand) {
+        return createResultVector(operand, index -> {
+            String value = operand.getDataAt(index);
+            RComplex complexValue = naCheck.convertStringToComplex(value);
+            if (RRuntime.isNA(complexValue)) {
+                warningBranch.enter();
+                RError.warning(RError.Message.NA_INTRODUCED_COERCION);
+            }
+            return complexValue;
+        });
     }
 
     @Specialization
@@ -230,44 +139,9 @@ public abstract class CastComplexNode extends CastNode {
         return vector;
     }
 
-    @Specialization(guards = {"!preserveNames", "preserveDimensions"})
-    protected RComplexVector doRawVectorDims(RRawVector operand) {
-        double[] ddata = dataFromRaw(operand);
-        RComplexVector ret = RDataFactory.createComplexVector(ddata, RDataFactory.COMPLETE_VECTOR, operand.getDimensions());
-        if (isAttrPreservation()) {
-            ret.copyRegAttributesFrom(operand);
-        }
-        return ret;
-    }
-
-    @Specialization(guards = {"preserveNames", "!preserveDimensions"})
-    protected RComplexVector doRawVectorNames(RRawVector operand) {
-        double[] ddata = dataFromRaw(operand);
-        RComplexVector ret = RDataFactory.createComplexVector(ddata, RDataFactory.COMPLETE_VECTOR, operand.getNames());
-        if (isAttrPreservation()) {
-            ret.copyRegAttributesFrom(operand);
-        }
-        return ret;
-    }
-
-    @Specialization(guards = {"preserveNames", "preserveDimensions"})
-    protected RComplexVector doRawVectorDimsNames(RRawVector operand) {
-        double[] ddata = dataFromRaw(operand);
-        RComplexVector ret = RDataFactory.createComplexVector(ddata, RDataFactory.COMPLETE_VECTOR, operand.getDimensions(), operand.getNames());
-        if (isAttrPreservation()) {
-            ret.copyRegAttributesFrom(operand);
-        }
-        return ret;
-    }
-
-    @Specialization(guards = {"!preserveNames", "!preserveDimensions"})
+    @Specialization
     protected RComplexVector doRawVector(RRawVector operand) {
-        double[] ddata = dataFromRaw(operand);
-        RComplexVector ret = RDataFactory.createComplexVector(ddata, RDataFactory.COMPLETE_VECTOR);
-        if (isAttrPreservation()) {
-            ret.copyRegAttributesFrom(operand);
-        }
-        return ret;
+        return createResultVector(operand, index -> RDataFactory.createComplex(operand.getDataAt(index).getValue(), 0));
     }
 
     @Fallback
@@ -275,57 +149,4 @@ public abstract class CastComplexNode extends CastNode {
     public int doOther(Object operand) {
         throw new ConversionFailedException(operand.getClass().getName());
     }
-
-    private RComplexVector performAbstractIntVector(RAbstractIntVector operand) {
-        naCheck.enable(operand);
-        double[] ddata = new double[operand.getLength() << 1];
-        for (int i = 0; i < operand.getLength(); i++) {
-            int value = operand.getDataAt(i);
-            RComplex complexValue = naCheck.convertIntToComplex(value);
-            int index = i << 1;
-            ddata[index] = complexValue.getRealPart();
-            ddata[index + 1] = complexValue.getImaginaryPart();
-        }
-        RComplexVector ret;
-        if (preserveDimensions() && preserveNames()) {
-            ret = RDataFactory.createComplexVector(ddata, naCheck.neverSeenNA(), operand.getDimensions(), operand.getNames());
-        } else if (preserveDimensions()) {
-            ret = RDataFactory.createComplexVector(ddata, naCheck.neverSeenNA(), operand.getDimensions());
-        } else if (preserveNames()) {
-            ret = RDataFactory.createComplexVector(ddata, naCheck.neverSeenNA(), operand.getNames());
-        } else {
-            ret = RDataFactory.createComplexVector(ddata, naCheck.neverSeenNA());
-        }
-        if (isAttrPreservation()) {
-            ret.copyRegAttributesFrom(operand);
-        }
-        return ret;
-    }
-
-    private RComplexVector performAbstractDoubleVector(RAbstractDoubleVector operand) {
-        naCheck.enable(operand);
-        double[] ddata = new double[operand.getLength() << 1];
-        for (int i = 0; i < operand.getLength(); i++) {
-            double value = operand.getDataAt(i);
-            RComplex complexValue = naCheck.convertDoubleToComplex(value);
-            int index = i << 1;
-            ddata[index] = complexValue.getRealPart();
-            ddata[index + 1] = complexValue.getImaginaryPart();
-        }
-        RComplexVector ret;
-        if (preserveDimensions() && preserveNames()) {
-            ret = RDataFactory.createComplexVector(ddata, naCheck.neverSeenNA(), operand.getDimensions(), operand.getNames());
-        } else if (preserveDimensions()) {
-            ret = RDataFactory.createComplexVector(ddata, naCheck.neverSeenNA(), operand.getDimensions());
-        } else if (preserveNames()) {
-            ret = RDataFactory.createComplexVector(ddata, naCheck.neverSeenNA(), operand.getNames());
-        } else {
-            ret = RDataFactory.createComplexVector(ddata, naCheck.neverSeenNA());
-        }
-        if (isAttrPreservation()) {
-            ret.copyRegAttributesFrom(operand);
-        }
-        return ret;
-    }
-
 }
diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastDoubleNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastDoubleNode.java
index 0a68928446201ed605fec7ffba0ac5b90aba160a..525d98a651664f5edac5003bcd4df612a07c7cc5 100644
--- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastDoubleNode.java
+++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastDoubleNode.java
@@ -22,10 +22,13 @@
  */
 package com.oracle.truffle.r.nodes.unary;
 
+import java.util.function.*;
+
 import com.oracle.truffle.api.*;
 import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
 import com.oracle.truffle.api.dsl.*;
 import com.oracle.truffle.api.frame.*;
+import com.oracle.truffle.api.utilities.*;
 import com.oracle.truffle.r.runtime.*;
 import com.oracle.truffle.r.runtime.data.*;
 import com.oracle.truffle.r.runtime.data.model.*;
@@ -34,6 +37,7 @@ import com.oracle.truffle.r.runtime.ops.na.*;
 public abstract class CastDoubleNode extends CastNode {
 
     private final NACheck naCheck = NACheck.create();
+    private final BranchProfile warningBranch = BranchProfile.create();
 
     public abstract Object executeDouble(VirtualFrame frame, int o);
 
@@ -48,7 +52,7 @@ public abstract class CastDoubleNode extends CastNode {
     private Object castDoubleRecursive(VirtualFrame frame, Object o) {
         if (recursiveCastDouble == null) {
             CompilerDirectives.transferToInterpreterAndInvalidate();
-            recursiveCastDouble = insert(CastDoubleNodeFactory.create(null, isNamesPreservation(), isDimensionsPreservation(), isAttrPreservation()));
+            recursiveCastDouble = insert(CastDoubleNodeFactory.create(null, isPreserveNames(), isDimensionsPreservation(), isAttrPreservation()));
         }
         return recursiveCastDouble.executeDouble(frame, o);
     }
@@ -74,6 +78,7 @@ public abstract class CastDoubleNode extends CastNode {
         naCheck.enable(operand);
         double result = naCheck.convertComplexToDouble(operand);
         if (operand.getImaginaryPart() != 0.0) {
+            warningBranch.enter();
             RError.warning(RError.Message.IMAGINARY_PARTS_DISCARDED_IN_COERCION);
         }
         return result;
@@ -90,6 +95,7 @@ public abstract class CastDoubleNode extends CastNode {
         naCheck.enable(operand);
         double result = naCheck.convertStringToDouble(operand);
         if (isNA(result)) {
+            warningBranch.enter();
             RError.warning(RError.Message.NA_INTRODUCED_COERCION);
         }
         return result;
@@ -100,17 +106,35 @@ public abstract class CastDoubleNode extends CastNode {
         return RRuntime.raw2double(operand);
     }
 
-    private double[] dataFromLogical(RLogicalVector operand) {
+    private RDoubleVector createResultVector(RAbstractVector operand, double[] ddata) {
+        RDoubleVector ret = RDataFactory.createDoubleVector(ddata, naCheck.neverSeenNA(), isPreserveDimensions() ? operand.getDimensions() : null, isPreserveNames() ? operand.getNames() : null);
+        if (isAttrPreservation()) {
+            ret.copyRegAttributesFrom(operand);
+        }
+        return ret;
+    }
+
+    private RDoubleVector createResultVector(RAbstractVector operand, IntToDoubleFunction elementFunction) {
         naCheck.enable(operand);
         double[] ddata = new double[operand.getLength()];
         for (int i = 0; i < operand.getLength(); i++) {
-            byte value = operand.getDataAt(i);
-            ddata[i] = naCheck.convertLogicalToDouble(value);
+            ddata[i] = elementFunction.applyAsDouble(i);
         }
-        return ddata;
+        return createResultVector(operand, ddata);
     }
 
-    private double[] dataFromString(RStringVector operand) {
+    @Specialization
+    protected RDoubleVector doIntVector(RAbstractIntVector operand) {
+        return createResultVector(operand, index -> naCheck.convertIntToDouble(operand.getDataAt(index)));
+    }
+
+    @Specialization
+    protected RDoubleVector doLogicalVectorDims(RLogicalVector operand) {
+        return createResultVector(operand, index -> naCheck.convertLogicalToDouble(operand.getDataAt(index)));
+    }
+
+    @Specialization
+    protected RDoubleVector doStringVector(RStringVector operand) {
         naCheck.enable(operand);
         double[] ddata = new double[operand.getLength()];
         boolean warning = false;
@@ -122,21 +146,14 @@ public abstract class CastDoubleNode extends CastNode {
             }
         }
         if (warning) {
+            warningBranch.enter();
             RError.warning(RError.Message.NA_INTRODUCED_COERCION);
         }
-        return ddata;
-    }
-
-    private static double[] dataFromRaw(RRawVector operand) {
-        double[] ddata = new double[operand.getLength()];
-        for (int i = 0; i < operand.getLength(); i++) {
-            RRaw value = operand.getDataAt(i);
-            ddata[i] = RRuntime.raw2double(value);
-        }
-        return ddata;
+        return createResultVector(operand, ddata);
     }
 
-    private double[] dataFromComplex(RComplexVector operand) {
+    @Specialization
+    protected RDoubleVector doComplexVector(RComplexVector operand) {
         naCheck.enable(operand);
         double[] ddata = new double[operand.getLength()];
         boolean warning = false;
@@ -148,179 +165,15 @@ public abstract class CastDoubleNode extends CastNode {
             }
         }
         if (warning) {
+            warningBranch.enter();
             RError.warning(RError.Message.IMAGINARY_PARTS_DISCARDED_IN_COERCION);
         }
-        return ddata;
-    }
-
-    @Specialization
-    protected RDoubleVector doIntVector(RIntVector operand) {
-        return performAbstractIntVector(operand);
+        return createResultVector(operand, ddata);
     }
 
     @Specialization
-    protected RDoubleVector doIntVector(RIntSequence operand) {
-        return performAbstractIntVector(operand);
-    }
-
-    @Specialization(guards = {"!preserveNames", "preserveDimensions"})
-    protected RDoubleVector doLogicalVectorDims(RLogicalVector operand) {
-        double[] ddata = dataFromLogical(operand);
-        RDoubleVector ret = RDataFactory.createDoubleVector(ddata, naCheck.neverSeenNA(), operand.getDimensions());
-        if (isAttrPreservation()) {
-            ret.copyRegAttributesFrom(operand);
-        }
-        return ret;
-    }
-
-    @Specialization(guards = {"preserveNames", "!preserveDimensions"})
-    protected RDoubleVector doLogicalVectorNames(RLogicalVector operand) {
-        double[] ddata = dataFromLogical(operand);
-        RDoubleVector ret = RDataFactory.createDoubleVector(ddata, naCheck.neverSeenNA(), operand.getNames());
-        if (isAttrPreservation()) {
-            ret.copyRegAttributesFrom(operand);
-        }
-        return ret;
-    }
-
-    @Specialization(guards = {"preserveNames", "preserveDimensions"})
-    protected RDoubleVector doLogicalVectorDimsNames(RLogicalVector operand) {
-        double[] ddata = dataFromLogical(operand);
-        RDoubleVector ret = RDataFactory.createDoubleVector(ddata, naCheck.neverSeenNA(), operand.getDimensions(), operand.getNames());
-        if (isAttrPreservation()) {
-            ret.copyRegAttributesFrom(operand);
-        }
-        return ret;
-    }
-
-    @Specialization(guards = {"!preserveNames", "!preserveDimensions"})
-    protected RDoubleVector doLogicalVector(RLogicalVector operand) {
-        double[] ddata = dataFromLogical(operand);
-        RDoubleVector ret = RDataFactory.createDoubleVector(ddata, naCheck.neverSeenNA());
-        if (isAttrPreservation()) {
-            ret.copyRegAttributesFrom(operand);
-        }
-        return ret;
-    }
-
-    @Specialization(guards = {"!preserveNames", "preserveDimensions"})
-    protected RDoubleVector doStringVectorDims(RStringVector operand) {
-        double[] ddata = dataFromString(operand);
-        RDoubleVector ret = RDataFactory.createDoubleVector(ddata, naCheck.neverSeenNA(), operand.getDimensions());
-        if (isAttrPreservation()) {
-            ret.copyRegAttributesFrom(operand);
-        }
-        return ret;
-    }
-
-    @Specialization(guards = {"preserveNames", "!preserveDimensions"})
-    protected RDoubleVector doStringVectorNames(RStringVector operand) {
-        double[] ddata = dataFromString(operand);
-        RDoubleVector ret = RDataFactory.createDoubleVector(ddata, naCheck.neverSeenNA(), operand.getNames());
-        if (isAttrPreservation()) {
-            ret.copyRegAttributesFrom(operand);
-        }
-        return ret;
-    }
-
-    @Specialization(guards = {"preserveNames", "preserveDimensions"})
-    protected RDoubleVector doStringVectorDimsNames(RStringVector operand) {
-        double[] ddata = dataFromString(operand);
-        RDoubleVector ret = RDataFactory.createDoubleVector(ddata, naCheck.neverSeenNA(), operand.getDimensions(), operand.getNames());
-        if (isAttrPreservation()) {
-            ret.copyRegAttributesFrom(operand);
-        }
-        return ret;
-    }
-
-    @Specialization(guards = {"!preserveNames", "!preserveDimensions"})
-    protected RDoubleVector doStringVector(RStringVector operand) {
-        double[] ddata = dataFromString(operand);
-        RDoubleVector ret = RDataFactory.createDoubleVector(ddata, naCheck.neverSeenNA());
-        if (isAttrPreservation()) {
-            ret.copyRegAttributesFrom(operand);
-        }
-        return ret;
-    }
-
-    @Specialization(guards = {"!preserveNames", "preserveDimensions"})
-    protected RDoubleVector doComplexVectorDims(RComplexVector operand) {
-        double[] ddata = dataFromComplex(operand);
-        RDoubleVector ret = RDataFactory.createDoubleVector(ddata, naCheck.neverSeenNA(), operand.getDimensions());
-        if (isAttrPreservation()) {
-            ret.copyRegAttributesFrom(operand);
-        }
-        return ret;
-    }
-
-    @Specialization(guards = {"preserveNames", "!preserveDimensions"})
-    protected RDoubleVector doComplexVectorNames(RComplexVector operand) {
-        double[] ddata = dataFromComplex(operand);
-        RDoubleVector ret = RDataFactory.createDoubleVector(ddata, naCheck.neverSeenNA(), operand.getNames());
-        if (isAttrPreservation()) {
-            ret.copyRegAttributesFrom(operand);
-        }
-        return ret;
-    }
-
-    @Specialization(guards = {"preserveNames", "preserveDimensions"})
-    protected RDoubleVector doComplexVectorDimsNames(RComplexVector operand) {
-        double[] ddata = dataFromComplex(operand);
-        RDoubleVector ret = RDataFactory.createDoubleVector(ddata, naCheck.neverSeenNA(), operand.getDimensions(), operand.getNames());
-        if (isAttrPreservation()) {
-            ret.copyRegAttributesFrom(operand);
-        }
-        return ret;
-    }
-
-    @Specialization(guards = {"!preserveNames", "!preserveDimensions"})
-    protected RDoubleVector doComplexVector(RComplexVector operand) {
-        double[] ddata = dataFromComplex(operand);
-        RDoubleVector ret = RDataFactory.createDoubleVector(ddata, naCheck.neverSeenNA());
-        if (isAttrPreservation()) {
-            ret.copyRegAttributesFrom(operand);
-        }
-        return ret;
-    }
-
-    @Specialization(guards = {"!preserveNames", "preserveDimensions"})
-    protected RDoubleVector doRawVectorDims(RRawVector vector) {
-        double[] ddata = dataFromRaw(vector);
-        RDoubleVector ret = RDataFactory.createDoubleVector(ddata, naCheck.neverSeenNA(), vector.getDimensions());
-        if (isAttrPreservation()) {
-            ret.copyRegAttributesFrom(vector);
-        }
-        return ret;
-    }
-
-    @Specialization(guards = {"preserveNames", "!preserveDimensions"})
-    protected RDoubleVector doRawVectorNames(RRawVector vector) {
-        double[] ddata = dataFromRaw(vector);
-        RDoubleVector ret = RDataFactory.createDoubleVector(ddata, naCheck.neverSeenNA(), vector.getNames());
-        if (isAttrPreservation()) {
-            ret.copyRegAttributesFrom(vector);
-        }
-        return ret;
-    }
-
-    @Specialization(guards = {"preserveNames", "preserveDimensions"})
-    protected RDoubleVector doRawVectorDimsNames(RRawVector vector) {
-        double[] ddata = dataFromRaw(vector);
-        RDoubleVector ret = RDataFactory.createDoubleVector(ddata, naCheck.neverSeenNA(), vector.getDimensions(), vector.getNames());
-        if (isAttrPreservation()) {
-            ret.copyRegAttributesFrom(vector);
-        }
-        return ret;
-    }
-
-    @Specialization(guards = {"!preserveNames", "!preserveDimensions"})
-    protected RDoubleVector doRawVector(RRawVector vector) {
-        double[] ddata = dataFromRaw(vector);
-        RDoubleVector ret = RDataFactory.createDoubleVector(ddata, naCheck.neverSeenNA());
-        if (isAttrPreservation()) {
-            ret.copyRegAttributesFrom(vector);
-        }
-        return ret;
+    protected RDoubleVector doRawVector(RRawVector operand) {
+        return createResultVector(operand, index -> RRuntime.raw2double(operand.getDataAt(index)));
     }
 
     @Specialization
@@ -352,10 +205,10 @@ public abstract class CastDoubleNode extends CastNode {
                     } else if (doubleVector.getLength() == 0) {
                         result[i] = RRuntime.DOUBLE_NA;
                     } else {
-                        throw cannotCoerceListError();
+                        throw throwCannotCoerceListError("numeric");
                     }
                 } else {
-                    throw cannotCoerceListError();
+                    throw throwCannotCoerceListError("numeric");
                 }
             }
         }
@@ -366,36 +219,9 @@ public abstract class CastDoubleNode extends CastNode {
         return ret;
     }
 
-    private RError cannotCoerceListError() {
-        throw RError.error(this.getSourceSection(), RError.Message.LIST_COERCION, "numeric");
-    }
-
     @Fallback
     @TruffleBoundary
     public double doOther(Object operand) {
         throw new ConversionFailedException(operand.getClass().getName());
     }
-
-    private RDoubleVector performAbstractIntVector(RAbstractIntVector operand) {
-        naCheck.enable(operand);
-        double[] ddata = new double[operand.getLength()];
-        for (int i = 0; i < operand.getLength(); i++) {
-            int value = operand.getDataAt(i);
-            ddata[i] = naCheck.convertIntToDouble(value);
-        }
-        RDoubleVector ret;
-        if (preserveDimensions() && preserveNames()) {
-            ret = RDataFactory.createDoubleVector(ddata, naCheck.neverSeenNA(), operand.getDimensions(), operand.getNames());
-        } else if (preserveDimensions()) {
-            ret = RDataFactory.createDoubleVector(ddata, naCheck.neverSeenNA(), operand.getDimensions());
-        } else if (preserveNames()) {
-            ret = RDataFactory.createDoubleVector(ddata, naCheck.neverSeenNA(), operand.getNames());
-        } else {
-            ret = RDataFactory.createDoubleVector(ddata, naCheck.neverSeenNA());
-        }
-        if (isAttrPreservation()) {
-            ret.copyRegAttributesFrom(operand);
-        }
-        return ret;
-    }
 }
diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastIntegerNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastIntegerNode.java
index 2f0c440b627709b8a42ca062be95ddea652924ed..096a057359af4234e6c5b2b5d865b8725f17ccc5 100644
--- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastIntegerNode.java
+++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastIntegerNode.java
@@ -26,13 +26,16 @@ import com.oracle.truffle.api.*;
 import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
 import com.oracle.truffle.api.dsl.*;
 import com.oracle.truffle.api.frame.*;
+import com.oracle.truffle.api.utilities.*;
 import com.oracle.truffle.r.runtime.*;
 import com.oracle.truffle.r.runtime.data.*;
+import com.oracle.truffle.r.runtime.data.model.*;
 import com.oracle.truffle.r.runtime.ops.na.*;
 
 public abstract class CastIntegerNode extends CastNode {
 
-    private final NACheck check = NACheck.create();
+    private final NACheck naCheck = NACheck.create();
+    private final BranchProfile warningBranch = BranchProfile.create();
 
     public abstract Object executeInt(VirtualFrame frame, int o);
 
@@ -47,7 +50,7 @@ public abstract class CastIntegerNode extends CastNode {
     private Object castIntegerRecursive(VirtualFrame frame, Object o) {
         if (recursiveCastInteger == null) {
             CompilerDirectives.transferToInterpreterAndInvalidate();
-            recursiveCastInteger = insert(CastIntegerNodeFactory.create(null, isNamesPreservation(), isDimensionsPreservation(), isAttrPreservation()));
+            recursiveCastInteger = insert(CastIntegerNodeFactory.create(null, isPreserveNames(), isDimensionsPreservation(), isAttrPreservation()));
         }
         return recursiveCastInteger.executeInt(frame, o);
     }
@@ -69,8 +72,8 @@ public abstract class CastIntegerNode extends CastNode {
 
     @Specialization
     protected int doDouble(double operand) {
-        check.enable(operand);
-        return check.convertDoubleToInt(operand);
+        naCheck.enable(operand);
+        return naCheck.convertDoubleToInt(operand);
     }
 
     @Specialization
@@ -85,15 +88,16 @@ public abstract class CastIntegerNode extends CastNode {
 
     @Specialization
     protected RIntSequence doDoubleSequence(RDoubleSequence operand) {
-        check.enable(operand);
-        return RDataFactory.createIntSequence(check.convertDoubleToInt(operand.getStart()), check.convertDoubleToInt(operand.getStride()), operand.getLength());
+        naCheck.enable(operand);
+        return RDataFactory.createIntSequence(naCheck.convertDoubleToInt(operand.getStart()), naCheck.convertDoubleToInt(operand.getStride()), operand.getLength());
     }
 
     @Specialization
     protected int doComplex(RComplex operand) {
-        check.enable(operand);
-        int result = check.convertComplexToInt(operand);
+        naCheck.enable(operand);
+        int result = naCheck.convertComplexToInt(operand);
         if (operand.getImaginaryPart() != 0.0) {
+            warningBranch.enter();
             RError.warning(RError.Message.IMAGINARY_PARTS_DISCARDED_IN_COERCION);
         }
         return result;
@@ -101,9 +105,10 @@ public abstract class CastIntegerNode extends CastNode {
 
     @Specialization
     protected int doCharacter(String operand) {
-        check.enable(operand);
-        int result = check.convertStringToInt(operand);
+        naCheck.enable(operand);
+        int result = naCheck.convertStringToInt(operand);
         if (isNA(result)) {
+            warningBranch.enter();
             RError.warning(RError.Message.NA_INTRODUCED_COERCION);
         }
         return result;
@@ -111,8 +116,8 @@ public abstract class CastIntegerNode extends CastNode {
 
     @Specialization
     protected int doBoolean(byte operand) {
-        check.enable(operand);
-        return check.convertLogicalToInt(operand);
+        naCheck.enable(operand);
+        return naCheck.convertLogicalToInt(operand);
     }
 
     @Specialization
@@ -120,262 +125,81 @@ public abstract class CastIntegerNode extends CastNode {
         return RRuntime.raw2int(operand);
     }
 
-    private int[] dataFromComplex(RComplexVector operand) {
-        check.enable(operand);
+    private RIntVector createResultVector(RAbstractVector operand, int[] idata) {
+        RIntVector ret = RDataFactory.createIntVector(idata, naCheck.neverSeenNA(), isPreserveDimensions() ? operand.getDimensions() : null, isPreserveNames() ? operand.getNames() : null);
+        if (isAttrPreservation()) {
+            ret.copyRegAttributesFrom(operand);
+        }
+        return ret;
+    }
+
+    @FunctionalInterface
+    private interface IntToIntFunction {
+        int apply(int value);
+    }
+
+    private RIntVector createResultVector(RAbstractVector operand, IntToIntFunction elementFunction) {
+        naCheck.enable(operand);
+        int[] idata = new int[operand.getLength()];
+        for (int i = 0; i < operand.getLength(); i++) {
+            idata[i] = elementFunction.apply(i);
+        }
+        return createResultVector(operand, idata);
+    }
+
+    @Specialization
+    protected RIntVector doComplexVector(RComplexVector operand) {
+        naCheck.enable(operand);
         int length = operand.getLength();
         int[] idata = new int[length];
         boolean warning = false;
         for (int i = 0; i < length; i++) {
             RComplex data = operand.getDataAt(i);
-            idata[i] = check.convertComplexToInt(data, false);
+            idata[i] = naCheck.convertComplexToInt(data, false);
             if (data.getImaginaryPart() != 0.0) {
                 warning = true;
             }
         }
         if (warning) {
+            warningBranch.enter();
             RError.warning(RError.Message.IMAGINARY_PARTS_DISCARDED_IN_COERCION);
         }
-        return idata;
+        return createResultVector(operand, idata);
     }
 
-    private int[] dataFromString(RStringVector operand) {
-        check.enable(operand);
+    @Specialization
+    protected RIntVector doStringVector(RStringVector operand) {
+        naCheck.enable(operand);
         int[] idata = new int[operand.getLength()];
         boolean warning = false;
         for (int i = 0; i < operand.getLength(); i++) {
             String value = operand.getDataAt(i);
-            idata[i] = check.convertStringToInt(value);
+            idata[i] = naCheck.convertStringToInt(value);
             if (RRuntime.isNA(idata[i])) {
                 warning = true;
             }
         }
         if (warning) {
+            warningBranch.enter();
             RError.warning(RError.Message.NA_INTRODUCED_COERCION);
         }
-        return idata;
-    }
-
-    private int[] dataFromLogical(RLogicalVector operand) {
-        check.enable(operand);
-        int[] idata = new int[operand.getLength()];
-        for (int i = 0; i < operand.getLength(); i++) {
-            byte value = operand.getDataAt(i);
-            idata[i] = check.convertLogicalToInt(value);
-        }
-        return idata;
-    }
-
-    private static int[] dataFromRaw(RRawVector operand) {
-        int[] idata = new int[operand.getLength()];
-        for (int i = 0; i < operand.getLength(); i++) {
-            RRaw value = operand.getDataAt(i);
-            idata[i] = RRuntime.raw2int(value);
-        }
-        return idata;
-    }
-
-    @Specialization(guards = {"!preserveNames", "preserveDimensions"})
-    protected RIntVector doComplexVectorDims(RComplexVector vector) {
-        int[] result = dataFromComplex(vector);
-        RIntVector ret = RDataFactory.createIntVector(result, check.neverSeenNA(), vector.getDimensions());
-        if (isAttrPreservation()) {
-            ret.copyRegAttributesFrom(vector);
-        }
-        return ret;
-    }
-
-    @Specialization(guards = {"preserveNames", "!preserveDimensions"})
-    protected RIntVector doComplexVectorNames(RComplexVector vector) {
-        int[] result = dataFromComplex(vector);
-        RIntVector ret = RDataFactory.createIntVector(result, check.neverSeenNA(), vector.getNames());
-        if (isAttrPreservation()) {
-            ret.copyRegAttributesFrom(vector);
-        }
-        return ret;
-    }
-
-    @Specialization(guards = {"preserveNames", "preserveDimensions"})
-    protected RIntVector doComplexVectorDimsNames(RComplexVector vector) {
-        int[] result = dataFromComplex(vector);
-        RIntVector ret = RDataFactory.createIntVector(result, check.neverSeenNA(), vector.getDimensions(), vector.getNames());
-        if (isAttrPreservation()) {
-            ret.copyRegAttributesFrom(vector);
-        }
-        return ret;
-    }
-
-    @Specialization(guards = {"!preserveNames", "!preserveDimensions"})
-    protected RIntVector doComplexVector(RComplexVector vector) {
-        int[] result = dataFromComplex(vector);
-        RIntVector ret = RDataFactory.createIntVector(result, check.neverSeenNA());
-        if (isAttrPreservation()) {
-            ret.copyRegAttributesFrom(vector);
-        }
-        return ret;
-    }
-
-    @Specialization(guards = {"!preserveNames", "preserveDimensions"})
-    protected RIntVector doStringVectorDims(RStringVector vector) {
-        int[] result = dataFromString(vector);
-        RIntVector ret = RDataFactory.createIntVector(result, check.neverSeenNA(), vector.getDimensions());
-        if (isAttrPreservation()) {
-            ret.copyRegAttributesFrom(vector);
-        }
-        return ret;
-    }
-
-    @Specialization(guards = {"preserveNames", "!preserveDimensions"})
-    protected RIntVector doStringVectorNames(RStringVector vector) {
-        int[] result = dataFromString(vector);
-        RIntVector ret = RDataFactory.createIntVector(result, check.neverSeenNA(), vector.getNames());
-        if (isAttrPreservation()) {
-            ret.copyRegAttributesFrom(vector);
-        }
-        return ret;
-    }
-
-    @Specialization(guards = {"preserveNames", "preserveDimensions"})
-    protected RIntVector doStringVectorDimsNames(RStringVector vector) {
-        int[] result = dataFromString(vector);
-        RIntVector ret = RDataFactory.createIntVector(result, check.neverSeenNA(), vector.getDimensions(), vector.getNames());
-        if (isAttrPreservation()) {
-            ret.copyRegAttributesFrom(vector);
-        }
-        return ret;
-    }
-
-    @Specialization(guards = {"!preserveNames", "!preserveDimensions"})
-    protected RIntVector doStringVector(RStringVector vector) {
-        int[] result = dataFromString(vector);
-        RIntVector ret = RDataFactory.createIntVector(result, check.neverSeenNA());
-        if (isAttrPreservation()) {
-            ret.copyRegAttributesFrom(vector);
-        }
-        return ret;
-    }
-
-    @Specialization(guards = {"!preserveNames", "preserveDimensions"})
-    protected RIntVector doLogicalVectorDims(RLogicalVector vector) {
-        int[] result = dataFromLogical(vector);
-        RIntVector ret = RDataFactory.createIntVector(result, check.neverSeenNA(), vector.getDimensions());
-        if (isAttrPreservation()) {
-            ret.copyRegAttributesFrom(vector);
-        }
-        return ret;
-    }
-
-    @Specialization(guards = {"preserveNames", "!preserveDimensions"})
-    protected RIntVector doLogicalVectorNames(RLogicalVector vector) {
-        int[] result = dataFromLogical(vector);
-        RIntVector ret = RDataFactory.createIntVector(result, check.neverSeenNA(), vector.getNames());
-        if (isAttrPreservation()) {
-            ret.copyRegAttributesFrom(vector);
-        }
-        return ret;
-    }
-
-    @Specialization(guards = {"preserveNames", "preserveDimensions"})
-    protected RIntVector doLogicalVectorDimsNames(RLogicalVector vector) {
-        int[] result = dataFromLogical(vector);
-        RIntVector ret = RDataFactory.createIntVector(result, check.neverSeenNA(), vector.getDimensions(), vector.getNames());
-        if (isAttrPreservation()) {
-            ret.copyRegAttributesFrom(vector);
-        }
-        return ret;
-    }
-
-    @Specialization(guards = {"!preserveNames", "!preserveDimensions"})
-    public RIntVector doLogicalVector(RLogicalVector vector) {
-        int[] result = dataFromLogical(vector);
-        RIntVector ret = RDataFactory.createIntVector(result, check.neverSeenNA());
-        if (isAttrPreservation()) {
-            ret.copyRegAttributesFrom(vector);
-        }
-        return ret;
-    }
-
-    @Specialization(guards = {"!preserveNames", "preserveDimensions"})
-    protected RIntVector doDoubleVectorDims(RDoubleVector vector) {
-        check.enable(vector);
-        int[] result = check.convertDoubleVectorToIntData(vector);
-        RIntVector ret = RDataFactory.createIntVector(result, check.neverSeenNA(), vector.getDimensions());
-        if (isAttrPreservation()) {
-            ret.copyRegAttributesFrom(vector);
-        }
-        return ret;
-    }
-
-    @Specialization(guards = {"preserveNames", "!preserveDimensions"})
-    protected RIntVector doDoubleVectorNames(RDoubleVector vector) {
-        check.enable(vector);
-        int[] result = check.convertDoubleVectorToIntData(vector);
-        RIntVector ret = RDataFactory.createIntVector(result, check.neverSeenNA(), vector.getNames());
-        if (isAttrPreservation()) {
-            ret.copyRegAttributesFrom(vector);
-        }
-        return ret;
-    }
-
-    @Specialization(guards = {"preserveNames", "preserveDimensions"})
-    protected RIntVector doDoubleVectorDimsNames(RDoubleVector vector) {
-        check.enable(vector);
-        int[] result = check.convertDoubleVectorToIntData(vector);
-        RIntVector ret = RDataFactory.createIntVector(result, check.neverSeenNA(), vector.getDimensions(), vector.getNames());
-        if (isAttrPreservation()) {
-            ret.copyRegAttributesFrom(vector);
-        }
-        return ret;
-    }
-
-    @Specialization(guards = {"!preserveNames", "!preserveDimensions"})
-    protected RIntVector doDoubleVector(RDoubleVector vector) {
-        check.enable(vector);
-        int[] result = check.convertDoubleVectorToIntData(vector);
-        RIntVector ret = RDataFactory.createIntVector(result, check.neverSeenNA());
-        if (isAttrPreservation()) {
-            ret.copyRegAttributesFrom(vector);
-        }
-        return ret;
-    }
-
-    @Specialization(guards = {"!preserveNames", "preserveDimensions"})
-    protected RIntVector doRawVectorDims(RRawVector vector) {
-        int[] result = dataFromRaw(vector);
-        RIntVector ret = RDataFactory.createIntVector(result, check.neverSeenNA(), vector.getDimensions());
-        if (isAttrPreservation()) {
-            ret.copyRegAttributesFrom(vector);
-        }
-        return ret;
+        return createResultVector(operand, idata);
     }
 
-    @Specialization(guards = {"preserveNames", "!preserveDimensions"})
-    protected RIntVector doRawVectorNames(RRawVector vector) {
-        int[] result = dataFromRaw(vector);
-        RIntVector ret = RDataFactory.createIntVector(result, check.neverSeenNA(), vector.getNames());
-        if (isAttrPreservation()) {
-            ret.copyRegAttributesFrom(vector);
-        }
-        return ret;
+    @Specialization
+    public RIntVector doLogicalVector(RLogicalVector operand) {
+        return createResultVector(operand, index -> naCheck.convertLogicalToInt(operand.getDataAt(index)));
     }
 
-    @Specialization(guards = {"preserveNames", "preserveDimensions"})
-    protected RIntVector doRawVectorDimsNames(RRawVector vector) {
-        int[] result = dataFromRaw(vector);
-        RIntVector ret = RDataFactory.createIntVector(result, check.neverSeenNA(), vector.getDimensions(), vector.getNames());
-        if (isAttrPreservation()) {
-            ret.copyRegAttributesFrom(vector);
-        }
-        return ret;
+    @Specialization
+    protected RIntVector doDoubleVector(RDoubleVector operand) {
+        naCheck.enable(operand);
+        return createResultVector(operand, naCheck.convertDoubleVectorToIntData(operand));
     }
 
-    @Specialization(guards = {"!preserveNames", "!preserveDimensions"})
-    protected RIntVector doRawVector(RRawVector vector) {
-        int[] result = dataFromRaw(vector);
-        RIntVector ret = RDataFactory.createIntVector(result, check.neverSeenNA());
-        if (isAttrPreservation()) {
-            ret.copyRegAttributesFrom(vector);
-        }
-        return ret;
+    @Specialization
+    protected RIntVector doRawVector(RRawVector operand) {
+        return createResultVector(operand, index -> RRuntime.raw2int(operand.getDataAt(index)));
     }
 
     @Specialization
@@ -397,28 +221,23 @@ public abstract class CastIntegerNode extends CastNode {
                     } else if (intVector.getLength() == 0) {
                         result[i] = RRuntime.INT_NA;
                     } else {
-                        throw cannotCoerceListError();
+                        throw throwCannotCoerceListError("integer");
                     }
                 } else {
-                    throw cannotCoerceListError();
+                    throw throwCannotCoerceListError("integer");
                 }
             }
         }
-        RIntVector ret = RDataFactory.createIntVector(result, check.neverSeenNA());
+        RIntVector ret = RDataFactory.createIntVector(result, naCheck.neverSeenNA());
         if (isAttrPreservation()) {
             ret.copyRegAttributesFrom(list);
         }
         return ret;
     }
 
-    private RError cannotCoerceListError() {
-        throw RError.error(this.getSourceSection(), RError.Message.LIST_COERCION, "integer");
-    }
-
     @Fallback
     @TruffleBoundary
     public int doOther(Object operand) {
         throw new ConversionFailedException(operand.getClass().getName());
     }
-
 }
diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastListNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastListNode.java
index 84c5863e47bb5307e7532bfe9896f0bf915a6c55..1c0133786222e3e28da4182a5bb92b80e7237999 100644
--- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastListNode.java
+++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastListNode.java
@@ -44,8 +44,7 @@ public abstract class CastListNode extends CastNode {
     }
 
     @Specialization
-    @SuppressWarnings("unused")
-    protected RList doNull(RNull operand) {
+    protected RList doNull(@SuppressWarnings("unused") RNull operand) {
         return RDataFactory.createList();
     }
 
@@ -65,16 +64,7 @@ public abstract class CastListNode extends CastNode {
         for (int i = 0; i < data.length; ++i) {
             data[i] = operand.getDataAtAsObject(i);
         }
-        RList ret;
-        if (preserveDimensions() && preserveNames()) {
-            ret = RDataFactory.createList(data, operand.getDimensions(), operand.getNames());
-        } else if (preserveDimensions()) {
-            ret = RDataFactory.createList(data, operand.getDimensions());
-        } else if (preserveNames()) {
-            ret = RDataFactory.createList(data, operand.getNames());
-        } else {
-            ret = RDataFactory.createList(data);
-        }
+        RList ret = RDataFactory.createList(data, isPreserveDimensions() ? operand.getDimensions() : null, isPreserveNames() ? operand.getNames() : null);
         if (isAttrPreservation()) {
             ret.copyRegAttributesFrom(operand);
         }
@@ -95,5 +85,4 @@ public abstract class CastListNode extends CastNode {
     protected RList doDataFrame(VirtualFrame frame, RDataFrame operand) {
         return castList(frame, operand.getVector());
     }
-
 }
diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastLogicalNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastLogicalNode.java
index dbdc08068ea5ea36204fbb0bd8c1fe013457fc63..0a6857b8a718338e1c25ff723bde49040e66f110 100644
--- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastLogicalNode.java
+++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastLogicalNode.java
@@ -44,7 +44,7 @@ public abstract class CastLogicalNode extends CastNode {
     private Object castLogicalRecursive(VirtualFrame frame, Object o) {
         if (recursiveCastLogical == null) {
             CompilerDirectives.transferToInterpreterAndInvalidate();
-            recursiveCastLogical = insert(CastLogicalNodeFactory.create(null, isNamesPreservation(), isDimensionsPreservation(), isAttrPreservation()));
+            recursiveCastLogical = insert(CastLogicalNodeFactory.create(null, isPreserveNames(), isDimensionsPreservation(), isAttrPreservation()));
         }
         return recursiveCastLogical.executeLogical(frame, o);
     }
@@ -88,33 +88,22 @@ public abstract class CastLogicalNode extends CastNode {
         return RRuntime.raw2logical(operand);
     }
 
-    private byte[] dataFromString(RStringVector operand) {
-        naCheck.enable(operand);
-        byte[] ldata = new byte[operand.getLength()];
-        for (int i = 0; i < operand.getLength(); i++) {
-            String value = operand.getDataAt(i);
-            ldata[i] = naCheck.convertStringToLogical(value);
-        }
-        return ldata;
+    @FunctionalInterface
+    private interface IntToByteFunction {
+        byte apply(int value);
     }
 
-    private byte[] dataFromComplex(RComplexVector operand) {
+    private RLogicalVector createResultVector(RAbstractVector operand, IntToByteFunction elementFunction) {
         naCheck.enable(operand);
-        byte[] ldata = new byte[operand.getLength()];
+        byte[] bdata = new byte[operand.getLength()];
         for (int i = 0; i < operand.getLength(); i++) {
-            RComplex value = operand.getDataAt(i);
-            ldata[i] = naCheck.convertComplexToLogical(value);
+            bdata[i] = elementFunction.apply(i);
         }
-        return ldata;
-    }
-
-    private static byte[] dataFromRaw(RRawVector operand) {
-        byte[] ldata = new byte[operand.getLength()];
-        for (int i = 0; i < operand.getLength(); i++) {
-            RRaw value = operand.getDataAt(i);
-            ldata[i] = RRuntime.raw2logical(value);
+        RLogicalVector ret = RDataFactory.createLogicalVector(bdata, naCheck.neverSeenNA(), isPreserveDimensions() ? operand.getDimensions() : null, isPreserveNames() ? operand.getNames() : null);
+        if (isAttrPreservation()) {
+            ret.copyRegAttributesFrom(operand);
         }
-        return ldata;
+        return ret;
     }
 
     @Specialization
@@ -123,143 +112,28 @@ public abstract class CastLogicalNode extends CastNode {
     }
 
     @Specialization
-    protected RLogicalVector doIntVector(RIntVector operand) {
-        return performAbstractIntVector(operand);
-    }
-
-    @Specialization
-    protected RLogicalVector doIntSequence(RIntSequence operand) {
-        return performAbstractIntVector(operand);
+    protected RLogicalVector doIntVector(RAbstractIntVector operand) {
+        return createResultVector(operand, index -> naCheck.convertIntToLogical(operand.getDataAt(index)));
     }
 
     @Specialization
-    protected RLogicalVector doDoubleVector(RDoubleVector operand) {
-        return performAbstractDoubleVector(operand);
+    protected RLogicalVector doDoubleVector(RAbstractDoubleVector operand) {
+        return createResultVector(operand, index -> naCheck.convertDoubleToLogical(operand.getDataAt(index)));
     }
 
     @Specialization
-    protected RLogicalVector doDoubleSequence(RDoubleSequence operand) {
-        return performAbstractDoubleVector(operand);
-    }
-
-    @Specialization(guards = {"!preserveNames", "preserveDimensions"})
-    protected RLogicalVector doStringVectorDims(RStringVector operand) {
-        byte[] ldata = dataFromString(operand);
-        RLogicalVector ret = RDataFactory.createLogicalVector(ldata, naCheck.neverSeenNA(), operand.getDimensions());
-        if (isAttrPreservation()) {
-            ret.copyRegAttributesFrom(operand);
-        }
-        return ret;
-    }
-
-    @Specialization(guards = {"preserveNames", "!preserveDimensions"})
-    protected RLogicalVector doStringVectorNames(RStringVector operand) {
-        byte[] ldata = dataFromString(operand);
-        RLogicalVector ret = RDataFactory.createLogicalVector(ldata, naCheck.neverSeenNA(), operand.getNames());
-        if (isAttrPreservation()) {
-            ret.copyRegAttributesFrom(operand);
-        }
-        return ret;
-    }
-
-    @Specialization(guards = {"preserveNames", "preserveDimensions"})
-    protected RLogicalVector doStringVectorDimsNames(RStringVector operand) {
-        byte[] ldata = dataFromString(operand);
-        RLogicalVector ret = RDataFactory.createLogicalVector(ldata, naCheck.neverSeenNA(), operand.getDimensions(), operand.getNames());
-        if (isAttrPreservation()) {
-            ret.copyRegAttributesFrom(operand);
-        }
-        return ret;
-    }
-
-    @Specialization(guards = {"!preserveNames", "!preserveDimensions"})
     protected RLogicalVector doStringVector(RStringVector operand) {
-        byte[] ldata = dataFromString(operand);
-        RLogicalVector ret = RDataFactory.createLogicalVector(ldata, naCheck.neverSeenNA());
-        if (isAttrPreservation()) {
-            ret.copyRegAttributesFrom(operand);
-        }
-        return ret;
-    }
-
-    @Specialization(guards = {"!preserveNames", "preserveDimensions"})
-    protected RLogicalVector doComplexVectorDims(RComplexVector operand) {
-        byte[] ldata = dataFromComplex(operand);
-        RLogicalVector ret = RDataFactory.createLogicalVector(ldata, naCheck.neverSeenNA(), operand.getDimensions());
-        if (isAttrPreservation()) {
-            ret.copyRegAttributesFrom(operand);
-        }
-        return ret;
-    }
-
-    @Specialization(guards = {"preserveNames", "!preserveDimensions"})
-    protected RLogicalVector doComplexVectorNames(RComplexVector operand) {
-        byte[] ldata = dataFromComplex(operand);
-        RLogicalVector ret = RDataFactory.createLogicalVector(ldata, naCheck.neverSeenNA(), operand.getNames());
-        if (isAttrPreservation()) {
-            ret.copyRegAttributesFrom(operand);
-        }
-        return ret;
-    }
-
-    @Specialization(guards = {"preserveNames", "preserveDimensions"})
-    protected RLogicalVector doComplexVectorDimsNames(RComplexVector operand) {
-        byte[] ldata = dataFromComplex(operand);
-        RLogicalVector ret = RDataFactory.createLogicalVector(ldata, naCheck.neverSeenNA(), operand.getDimensions(), operand.getNames());
-        if (isAttrPreservation()) {
-            ret.copyRegAttributesFrom(operand);
-        }
-        return ret;
+        return createResultVector(operand, index -> naCheck.convertStringToLogical(operand.getDataAt(index)));
     }
 
-    @Specialization(guards = {"!preserveNames", "!preserveDimensions"})
+    @Specialization
     protected RLogicalVector doComplexVector(RComplexVector operand) {
-        byte[] ldata = dataFromComplex(operand);
-        RLogicalVector ret = RDataFactory.createLogicalVector(ldata, naCheck.neverSeenNA());
-        if (isAttrPreservation()) {
-            ret.copyRegAttributesFrom(operand);
-        }
-        return ret;
+        return createResultVector(operand, index -> naCheck.convertComplexToLogical(operand.getDataAt(index)));
     }
 
-    @Specialization(guards = {"!preserveNames", "preserveDimensions"})
+    @Specialization
     protected RLogicalVector doRawVectorDims(RRawVector operand) {
-        byte[] ldata = dataFromRaw(operand);
-        RLogicalVector ret = RDataFactory.createLogicalVector(ldata, RDataFactory.COMPLETE_VECTOR, operand.getDimensions());
-        if (isAttrPreservation()) {
-            ret.copyRegAttributesFrom(operand);
-        }
-        return ret;
-    }
-
-    @Specialization(guards = {"preserveNames", "!preserveDimensions"})
-    protected RLogicalVector doRawVectorNames(RRawVector operand) {
-        byte[] ldata = dataFromRaw(operand);
-        RLogicalVector ret = RDataFactory.createLogicalVector(ldata, RDataFactory.COMPLETE_VECTOR, operand.getNames());
-        if (isAttrPreservation()) {
-            ret.copyRegAttributesFrom(operand);
-        }
-        return ret;
-    }
-
-    @Specialization(guards = {"preserveNames", "preserveDimensions"})
-    protected RLogicalVector doRawVectorDimsNames(RRawVector operand) {
-        byte[] ldata = dataFromRaw(operand);
-        RLogicalVector ret = RDataFactory.createLogicalVector(ldata, RDataFactory.COMPLETE_VECTOR, operand.getDimensions(), operand.getNames());
-        if (isAttrPreservation()) {
-            ret.copyRegAttributesFrom(operand);
-        }
-        return ret;
-    }
-
-    @Specialization(guards = {"!preserveNames", "!preserveDimensions"})
-    protected RLogicalVector doRawVector(RRawVector operand) {
-        byte[] ldata = dataFromRaw(operand);
-        RLogicalVector ret = RDataFactory.createLogicalVector(ldata, RDataFactory.COMPLETE_VECTOR);
-        if (isAttrPreservation()) {
-            ret.copyRegAttributesFrom(operand);
-        }
-        return ret;
+        return createResultVector(operand, index -> RRuntime.raw2logical(operand.getDataAt(index)));
     }
 
     @Specialization
@@ -281,10 +155,10 @@ public abstract class CastLogicalNode extends CastNode {
                     } else if (logicalVector.getLength() == 0) {
                         result[i] = RRuntime.LOGICAL_NA;
                     } else {
-                        throw cannotCoerceListError();
+                        throw throwCannotCoerceListError("logical");
                     }
                 } else {
-                    throw cannotCoerceListError();
+                    throw throwCannotCoerceListError("logical");
                 }
             }
         }
@@ -295,10 +169,6 @@ public abstract class CastLogicalNode extends CastNode {
         return ret;
     }
 
-    private RError cannotCoerceListError() {
-        throw RError.error(this.getSourceSection(), RError.Message.LIST_COERCION, "logical");
-    }
-
     @Specialization
     protected RArgsValuesAndNames doArgsValueAndNames(RArgsValuesAndNames values) {
         return values;
@@ -314,50 +184,4 @@ public abstract class CastLogicalNode extends CastNode {
     public int doOther(Object operand) {
         throw new ConversionFailedException(operand.getClass().getName());
     }
-
-    private RLogicalVector performAbstractIntVector(RAbstractIntVector operand) {
-        naCheck.enable(operand);
-        byte[] ddata = new byte[operand.getLength()];
-        for (int i = 0; i < operand.getLength(); i++) {
-            int value = operand.getDataAt(i);
-            ddata[i] = naCheck.convertIntToLogical(value);
-        }
-        RLogicalVector ret;
-        if (preserveDimensions() && preserveNames()) {
-            ret = RDataFactory.createLogicalVector(ddata, naCheck.neverSeenNA(), operand.getDimensions(), operand.getNames());
-        } else if (preserveDimensions()) {
-            ret = RDataFactory.createLogicalVector(ddata, naCheck.neverSeenNA(), operand.getDimensions());
-        } else if (preserveNames()) {
-            ret = RDataFactory.createLogicalVector(ddata, naCheck.neverSeenNA(), operand.getNames());
-        } else {
-            ret = RDataFactory.createLogicalVector(ddata, naCheck.neverSeenNA());
-        }
-        if (isAttrPreservation()) {
-            ret.copyRegAttributesFrom(operand);
-        }
-        return ret;
-    }
-
-    private RLogicalVector performAbstractDoubleVector(RAbstractDoubleVector operand) {
-        naCheck.enable(operand);
-        byte[] ddata = new byte[operand.getLength()];
-        for (int i = 0; i < operand.getLength(); i++) {
-            double value = operand.getDataAt(i);
-            ddata[i] = naCheck.convertDoubleToLogical(value);
-        }
-        RLogicalVector ret;
-        if (preserveDimensions() && preserveNames()) {
-            ret = RDataFactory.createLogicalVector(ddata, naCheck.neverSeenNA(), operand.getDimensions(), operand.getNames());
-        } else if (preserveDimensions()) {
-            ret = RDataFactory.createLogicalVector(ddata, naCheck.neverSeenNA(), operand.getDimensions());
-        } else if (preserveNames()) {
-            ret = RDataFactory.createLogicalVector(ddata, naCheck.neverSeenNA(), operand.getNames());
-        } else {
-            ret = RDataFactory.createLogicalVector(ddata, naCheck.neverSeenNA());
-        }
-        if (isAttrPreservation()) {
-            ret.copyRegAttributesFrom(operand);
-        }
-        return ret;
-    }
 }
diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastNode.java
index 25ebaf0870b74a5aec7bf80d7443719dcd2aeded..b06e0110514929340b5c5058744a7d27eb5ca39c 100644
--- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastNode.java
+++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastNode.java
@@ -24,24 +24,28 @@ package com.oracle.truffle.r.nodes.unary;
 
 import com.oracle.truffle.api.dsl.*;
 import com.oracle.truffle.api.frame.*;
+import com.oracle.truffle.api.utilities.*;
+import com.oracle.truffle.r.runtime.*;
 
-@NodeFields({@NodeField(name = "namesPreservation", type = boolean.class), @NodeField(name = "dimensionsPreservation", type = boolean.class),
-                @NodeField(name = "attrPreservation", type = boolean.class)})
+@NodeFields({@NodeField(name = "preserveNames", type = boolean.class), @NodeField(name = "dimensionsPreservation", type = boolean.class), @NodeField(name = "attrPreservation", type = boolean.class)})
 public abstract class CastNode extends UnaryNode {
 
+    private final BranchProfile listCoercionErrorBranch = BranchProfile.create();
+
     public abstract Object executeCast(VirtualFrame frame, Object value);
 
-    protected abstract boolean isNamesPreservation();
+    protected abstract boolean isPreserveNames();
 
     protected abstract boolean isDimensionsPreservation();
 
     protected abstract boolean isAttrPreservation();
 
-    protected boolean preserveNames() {
-        return isNamesPreservation();
+    protected boolean isPreserveDimensions() {
+        return isDimensionsPreservation();
     }
 
-    protected boolean preserveDimensions() {
-        return isDimensionsPreservation();
+    protected RError throwCannotCoerceListError(String type) {
+        listCoercionErrorBranch.enter();
+        throw RError.error(getSourceSection(), RError.Message.LIST_COERCION, type);
     }
 }
diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastRawNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastRawNode.java
index 1a8120ef3980b4e450bfbe426f91c561f82e16ca..82b85b9192c6a318fe9e7c8902356fac0876ebf8 100644
--- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastRawNode.java
+++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastRawNode.java
@@ -25,12 +25,15 @@ package com.oracle.truffle.r.nodes.unary;
 import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
 import com.oracle.truffle.api.dsl.*;
 import com.oracle.truffle.api.frame.*;
+import com.oracle.truffle.api.utilities.*;
 import com.oracle.truffle.r.runtime.*;
 import com.oracle.truffle.r.runtime.data.*;
 import com.oracle.truffle.r.runtime.data.model.*;
 
 public abstract class CastRawNode extends CastNode {
 
+    private final BranchProfile warningBranch = BranchProfile.create();
+
     public abstract Object executeRaw(VirtualFrame frame, int o);
 
     public abstract Object executeRaw(VirtualFrame frame, double o);
@@ -48,6 +51,7 @@ public abstract class CastRawNode extends CastNode {
     protected RRaw doInt(int operand) {
         int intResult = RRuntime.int2rawIntValue(operand);
         if (intResult != operand) {
+            warningBranch.enter();
             RError.warning(RError.Message.OUT_OF_RANGE);
         }
         return RDataFactory.createRaw((byte) intResult);
@@ -57,6 +61,7 @@ public abstract class CastRawNode extends CastNode {
     protected RRaw doDouble(double operand) {
         int intResult = RRuntime.double2rawIntValue(operand);
         if (intResult != (int) operand) {
+            warningBranch.enter();
             RError.warning(RError.Message.OUT_OF_RANGE);
         }
         return RDataFactory.createRaw((byte) intResult);
@@ -66,9 +71,11 @@ public abstract class CastRawNode extends CastNode {
     protected RRaw doComplex(RComplex operand) {
         int intResult = RRuntime.complex2rawIntValue(operand);
         if (operand.getImaginaryPart() != 0) {
+            warningBranch.enter();
             RError.warning(RError.Message.IMAGINARY_PARTS_DISCARDED_IN_COERCION);
         }
         if (intResult != (int) operand.getRealPart()) {
+            warningBranch.enter();
             RError.warning(RError.Message.OUT_OF_RANGE);
         }
         return RDataFactory.createRaw((byte) intResult);
@@ -91,36 +98,42 @@ public abstract class CastRawNode extends CastNode {
         // need to cast to int to catch conversion warnings
         int intVal = RRuntime.string2int(operand);
         if (RRuntime.isNA(intVal)) {
+            warningBranch.enter();
             RError.warning(RError.Message.NA_INTRODUCED_COERCION);
         }
         return doInt(intVal);
     }
 
-    private static byte[] dataFromComplex(RComplexVector operand) {
-        byte[] bdata = new byte[operand.getLength()];
-        boolean imaginaryDiscardedWarning = false;
-        boolean outOfRangeWarning = false;
-        for (int i = 0; i < operand.getLength(); i++) {
-            RComplex complexVal = operand.getDataAt(i);
-            int intRawValue = RRuntime.complex2rawIntValue(complexVal);
-            if (complexVal.getImaginaryPart() != 0.0) {
-                imaginaryDiscardedWarning = true;
-            }
-            if ((int) complexVal.getRealPart() != intRawValue) {
-                outOfRangeWarning = true;
+    private RRawVector createResultVector(RAbstractVector operand, byte[] bdata) {
+        RRawVector ret = RDataFactory.createRawVector(bdata, isPreserveDimensions() ? operand.getDimensions() : null, isPreserveNames() ? operand.getNames() : null);
+        if (isAttrPreservation()) {
+            ret.copyRegAttributesFrom(operand);
+        }
+        return ret;
+    }
+
+    @Specialization
+    protected RRawVector doIntVector(RAbstractIntVector operand) {
+        int length = operand.getLength();
+        byte[] bdata = new byte[length];
+        boolean warning = false;
+        for (int i = 0; i < length; ++i) {
+            int intValue = operand.getDataAt(i);
+            int intRawValue = RRuntime.int2rawIntValue(intValue);
+            if (intRawValue != intValue) {
+                warning = true;
             }
             bdata[i] = (byte) intRawValue;
         }
-        if (imaginaryDiscardedWarning) {
-            RError.warning(RError.Message.IMAGINARY_PARTS_DISCARDED_IN_COERCION);
-        }
-        if (outOfRangeWarning) {
+        if (warning) {
+            warningBranch.enter();
             RError.warning(RError.Message.OUT_OF_RANGE);
         }
-        return bdata;
+        return createResultVector(operand, bdata);
     }
 
-    private static byte[] dataFromLogical(RLogicalVector operand) {
+    @Specialization
+    protected RRawVector doLogicalVector(RLogicalVector operand) {
         byte[] bdata = new byte[operand.getLength()];
         boolean warning = false;
         for (int i = 0; i < operand.getLength(); i++) {
@@ -132,12 +145,14 @@ public abstract class CastRawNode extends CastNode {
             bdata[i] = (byte) intRawValue;
         }
         if (warning) {
+            warningBranch.enter();
             RError.warning(RError.Message.OUT_OF_RANGE);
         }
-        return bdata;
+        return createResultVector(operand, bdata);
     }
 
-    private static byte[] dataFromString(RStringVector operand) {
+    @Specialization
+    protected RRawVector doStringVector(RStringVector operand) {
         byte[] bdata = new byte[operand.getLength()];
         boolean naCoercionWarning = false;
         boolean outOfRangeWarning = false;
@@ -153,152 +168,61 @@ public abstract class CastRawNode extends CastNode {
             bdata[i] = (byte) intRawValue;
         }
         if (naCoercionWarning) {
+            warningBranch.enter();
             RError.warning(RError.Message.NA_INTRODUCED_COERCION);
         }
         if (outOfRangeWarning) {
+            warningBranch.enter();
             RError.warning(RError.Message.OUT_OF_RANGE);
         }
-        return bdata;
+        return createResultVector(operand, bdata);
     }
 
     @Specialization
-    protected RRawVector doIntVector(RIntVector value) {
-        return performAbstractIntVector(value);
-    }
-
-    @Specialization
-    protected RRawVector doIntSequence(RIntSequence value) {
-        return performAbstractIntVector(value);
-    }
-
-    @Specialization(guards = {"!preserveNames", "preserveDimensions"})
-    protected RRawVector doLogicalVectorDims(RLogicalVector operand) {
-        byte[] bdata = dataFromLogical(operand);
-        RRawVector ret = RDataFactory.createRawVector(bdata, operand.getDimensions());
-        if (isAttrPreservation()) {
-            ret.copyRegAttributesFrom(operand);
-        }
-        return ret;
-    }
-
-    @Specialization(guards = {"preserveNames", "!preserveDimensions"})
-    protected RRawVector doLogicalVectorNames(RLogicalVector operand) {
-        byte[] bdata = dataFromLogical(operand);
-        RRawVector ret = RDataFactory.createRawVector(bdata, operand.getNames());
-        if (isAttrPreservation()) {
-            ret.copyRegAttributesFrom(operand);
-        }
-        return ret;
-    }
-
-    @Specialization(guards = {"preserveNames", "preserveDimensions"})
-    protected RRawVector doLogicalVectorDimsNames(RLogicalVector operand) {
-        byte[] bdata = dataFromLogical(operand);
-        RRawVector ret = RDataFactory.createRawVector(bdata, operand.getDimensions(), operand.getNames());
-        if (isAttrPreservation()) {
-            ret.copyRegAttributesFrom(operand);
-        }
-        return ret;
-    }
-
-    @Specialization(guards = {"!preserveNames", "!preserveDimensions"})
-    protected RRawVector doLogicalVector(RLogicalVector operand) {
-        byte[] bdata = dataFromLogical(operand);
-        RRawVector ret = RDataFactory.createRawVector(bdata);
-        if (isAttrPreservation()) {
-            ret.copyRegAttributesFrom(operand);
-        }
-        return ret;
-    }
-
-    @Specialization(guards = {"!preserveNames", "preserveDimensions"})
-    protected RRawVector doStringVectorDims(RStringVector operand) {
-        byte[] bdata = dataFromString(operand);
-        RRawVector ret = RDataFactory.createRawVector(bdata, operand.getDimensions());
-        if (isAttrPreservation()) {
-            ret.copyRegAttributesFrom(operand);
-        }
-        return ret;
-    }
-
-    @Specialization(guards = {"preserveNames", "!preserveDimensions"})
-    protected RRawVector doStringVectorNames(RStringVector operand) {
-        byte[] bdata = dataFromString(operand);
-        RRawVector ret = RDataFactory.createRawVector(bdata, operand.getNames());
-        if (isAttrPreservation()) {
-            ret.copyRegAttributesFrom(operand);
-        }
-        return ret;
-    }
-
-    @Specialization(guards = {"preserveNames", "preserveDimensions"})
-    protected RRawVector doStringVectorDimsNames(RStringVector operand) {
-        byte[] bdata = dataFromString(operand);
-        RRawVector ret = RDataFactory.createRawVector(bdata, operand.getDimensions(), operand.getNames());
-        if (isAttrPreservation()) {
-            ret.copyRegAttributesFrom(operand);
-        }
-        return ret;
-    }
-
-    @Specialization(guards = {"!preserveNames", "!preserveDimensions"})
-    protected RRawVector doStringVector(RStringVector operand) {
-        byte[] bdata = dataFromString(operand);
-        RRawVector ret = RDataFactory.createRawVector(bdata);
-        if (isAttrPreservation()) {
-            ret.copyRegAttributesFrom(operand);
+    protected RRawVector doComplexVector(RComplexVector operand) {
+        byte[] bdata = new byte[operand.getLength()];
+        boolean imaginaryDiscardedWarning = false;
+        boolean outOfRangeWarning = false;
+        for (int i = 0; i < operand.getLength(); i++) {
+            RComplex complexVal = operand.getDataAt(i);
+            int intRawValue = RRuntime.complex2rawIntValue(complexVal);
+            if (complexVal.getImaginaryPart() != 0.0) {
+                imaginaryDiscardedWarning = true;
+            }
+            if ((int) complexVal.getRealPart() != intRawValue) {
+                outOfRangeWarning = true;
+            }
+            bdata[i] = (byte) intRawValue;
         }
-        return ret;
-    }
-
-    @Specialization(guards = {"!preserveNames", "preserveDimensions"})
-    protected RRawVector doRawVectorDims(RComplexVector operand) {
-        byte[] bdata = dataFromComplex(operand);
-        RRawVector ret = RDataFactory.createRawVector(bdata, operand.getDimensions());
-        if (isAttrPreservation()) {
-            ret.copyRegAttributesFrom(operand);
+        if (imaginaryDiscardedWarning) {
+            warningBranch.enter();
+            RError.warning(RError.Message.IMAGINARY_PARTS_DISCARDED_IN_COERCION);
         }
-        return ret;
-    }
-
-    @Specialization(guards = {"preserveNames", "!preserveDimensions"})
-    protected RRawVector doComplexVectorNames(RComplexVector operand) {
-        byte[] bdata = dataFromComplex(operand);
-        RRawVector ret = RDataFactory.createRawVector(bdata, operand.getNames());
-        if (isAttrPreservation()) {
-            ret.copyRegAttributesFrom(operand);
+        if (outOfRangeWarning) {
+            warningBranch.enter();
+            RError.warning(RError.Message.OUT_OF_RANGE);
         }
-        return ret;
+        return createResultVector(operand, bdata);
     }
 
-    @Specialization(guards = {"preserveNames", "preserveDimensions"})
-    protected RRawVector doComplexVectorDimsNames(RComplexVector operand) {
-        byte[] bdata = dataFromComplex(operand);
-        RRawVector ret = RDataFactory.createRawVector(bdata, operand.getDimensions(), operand.getNames());
-        if (isAttrPreservation()) {
-            ret.copyRegAttributesFrom(operand);
+    @Specialization
+    protected RRawVector doDoubleVector(RAbstractDoubleVector operand) {
+        int length = operand.getLength();
+        byte[] bdata = new byte[length];
+        boolean warning = false;
+        for (int i = 0; i < length; ++i) {
+            double doubleValue = operand.getDataAt(i);
+            int intRawValue = RRuntime.double2rawIntValue(doubleValue);
+            if (intRawValue != (int) doubleValue) {
+                warning = true;
+            }
+            bdata[i] = (byte) intRawValue;
         }
-        return ret;
-    }
-
-    @Specialization(guards = {"!preserveNames", "!preserveDimensions"})
-    protected RRawVector doComplexVector(RComplexVector operand) {
-        byte[] bdata = dataFromComplex(operand);
-        RRawVector ret = RDataFactory.createRawVector(bdata);
-        if (isAttrPreservation()) {
-            ret.copyRegAttributesFrom(operand);
+        if (warning) {
+            warningBranch.enter();
+            RError.warning(RError.Message.OUT_OF_RANGE);
         }
-        return ret;
-    }
-
-    @Specialization
-    protected RRawVector doDoubleVector(RDoubleVector value) {
-        return performAbstractDoubleVector(value);
-    }
-
-    @Specialization
-    protected RRawVector doDoubleSequence(RDoubleSequence value) {
-        return performAbstractDoubleVector(value);
+        return createResultVector(operand, bdata);
     }
 
     @Specialization
@@ -311,66 +235,4 @@ public abstract class CastRawNode extends CastNode {
     public int doOther(Object operand) {
         throw new ConversionFailedException(operand.getClass().getName());
     }
-
-    private RRawVector performAbstractIntVector(RAbstractIntVector value) {
-        int length = value.getLength();
-        byte[] array = new byte[length];
-        boolean warning = false;
-        for (int i = 0; i < length; ++i) {
-            int intValue = value.getDataAt(i);
-            int intRawValue = RRuntime.int2rawIntValue(intValue);
-            if (intRawValue != intValue) {
-                warning = true;
-            }
-            array[i] = (byte) intRawValue;
-        }
-        if (warning) {
-            RError.warning(RError.Message.OUT_OF_RANGE);
-        }
-        RRawVector ret;
-        if (preserveDimensions() && preserveNames()) {
-            ret = RDataFactory.createRawVector(array, value.getDimensions(), value.getNames());
-        } else if (preserveDimensions()) {
-            ret = RDataFactory.createRawVector(array, value.getDimensions());
-        } else if (preserveNames()) {
-            ret = RDataFactory.createRawVector(array, value.getNames());
-        } else {
-            ret = RDataFactory.createRawVector(array);
-        }
-        if (isAttrPreservation()) {
-            ret.copyRegAttributesFrom(value);
-        }
-        return ret;
-    }
-
-    private RRawVector performAbstractDoubleVector(RAbstractDoubleVector value) {
-        int length = value.getLength();
-        byte[] array = new byte[length];
-        boolean warning = false;
-        for (int i = 0; i < length; ++i) {
-            double doubleValue = value.getDataAt(i);
-            int intRawValue = RRuntime.double2rawIntValue(doubleValue);
-            if (intRawValue != (int) doubleValue) {
-                warning = true;
-            }
-            array[i] = (byte) intRawValue;
-        }
-        if (warning) {
-            RError.warning(RError.Message.OUT_OF_RANGE);
-        }
-        RRawVector ret;
-        if (preserveDimensions() && preserveNames()) {
-            ret = RDataFactory.createRawVector(array, value.getDimensions(), value.getNames());
-        } else if (preserveDimensions()) {
-            ret = RDataFactory.createRawVector(array, value.getDimensions());
-        } else if (preserveNames()) {
-            ret = RDataFactory.createRawVector(array, value.getNames());
-        } else {
-            ret = RDataFactory.createRawVector(array);
-        }
-        if (isAttrPreservation()) {
-            ret.copyRegAttributesFrom(value);
-        }
-        return ret;
-    }
 }
diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastStringNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastStringNode.java
index 1e7de398198a36764c5876117ed734f7138c5d03..4717be1f29d280a3beb9f5f8312abfa54ac99bbc 100644
--- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastStringNode.java
+++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastStringNode.java
@@ -22,6 +22,8 @@
  */
 package com.oracle.truffle.r.nodes.unary;
 
+import java.util.function.*;
+
 import com.oracle.truffle.api.dsl.*;
 import com.oracle.truffle.api.frame.*;
 import com.oracle.truffle.r.runtime.data.*;
@@ -72,40 +74,16 @@ public abstract class CastStringNode extends CastNode {
         return toString.executeString(frame, value);
     }
 
-    private String[] dataFromLogical(VirtualFrame frame, RLogicalVector operand) {
-        String[] sdata = new String[operand.getLength()];
-        for (int i = 0; i < operand.getLength(); i++) {
-            byte value = operand.getDataAt(i);
-            sdata[i] = toString.executeString(frame, value);
-        }
-        return sdata;
-    }
-
-    private String[] dataFromComplex(VirtualFrame frame, RComplexVector operand) {
-        String[] sdata = new String[operand.getLength()];
-        for (int i = 0; i < operand.getLength(); i++) {
-            RComplex value = operand.getDataAt(i);
-            sdata[i] = toString.executeString(frame, value);
-        }
-        return sdata;
-    }
-
-    private String[] dataFromRaw(VirtualFrame frame, RRawVector operand) {
+    private RStringVector createResultVector(RAbstractVector operand, IntFunction<String> elementFunction) {
         String[] sdata = new String[operand.getLength()];
         for (int i = 0; i < operand.getLength(); i++) {
-            RRaw value = operand.getDataAt(i);
-            sdata[i] = toString.executeString(frame, value);
+            sdata[i] = elementFunction.apply(i);
         }
-        return sdata;
-    }
-
-    private String[] dataFromList(VirtualFrame frame, RList operand) {
-        String[] sdata = new String[operand.getLength()];
-        for (int i = 0; i < operand.getLength(); i++) {
-            Object value = operand.getDataAt(i);
-            sdata[i] = toString.executeString(frame, value);
+        RStringVector ret = RDataFactory.createStringVector(sdata, RDataFactory.COMPLETE_VECTOR, isPreserveDimensions() ? operand.getDimensions() : null, isPreserveNames() ? operand.getNames() : null);
+        if (isAttrPreservation()) {
+            ret.copyRegAttributesFrom(operand);
         }
-        return sdata;
+        return ret;
     }
 
     @Specialization(guards = "isZeroLength")
@@ -119,183 +97,33 @@ public abstract class CastStringNode extends CastNode {
     }
 
     @Specialization(guards = "!isZeroLength")
-    protected RStringVector doIntVector(VirtualFrame frame, RIntVector vector) {
-        return performAbstractIntVector(frame, vector);
+    protected RStringVector doIntVector(VirtualFrame frame, RAbstractIntVector operand) {
+        return createResultVector(operand, index -> toString.executeString(frame, operand.getDataAt(index)));
     }
 
     @Specialization(guards = "!isZeroLength")
-    protected RStringVector doDoubleVector(VirtualFrame frame, RDoubleVector vector) {
-        return performAbstractDoubleVector(frame, vector);
+    protected RStringVector doDoubleVector(VirtualFrame frame, RAbstractDoubleVector operand) {
+        return createResultVector(operand, index -> toString.executeString(frame, operand.getDataAt(index)));
     }
 
     @Specialization(guards = "!isZeroLength")
-    protected RStringVector doIntSequence(VirtualFrame frame, RIntSequence vector) {
-        return performAbstractIntVector(frame, vector);
+    protected RStringVector doLogicalVector(VirtualFrame frame, RLogicalVector operand) {
+        return createResultVector(operand, index -> toString.executeString(frame, operand.getDataAt(index)));
     }
 
     @Specialization(guards = "!isZeroLength")
-    protected RStringVector doDoubleSequence(VirtualFrame frame, RDoubleSequence vector) {
-        return performAbstractDoubleVector(frame, vector);
-    }
-
-    @Specialization(guards = {"!isZeroLength", "!preserveNames", "preserveDimensions"})
-    protected RStringVector doLogicalVectorDims(VirtualFrame frame, RLogicalVector vector) {
-        String[] result = dataFromLogical(frame, vector);
-        RStringVector ret = RDataFactory.createStringVector(result, RDataFactory.COMPLETE_VECTOR, vector.getDimensions());
-        if (isAttrPreservation()) {
-            ret.copyRegAttributesFrom(vector);
-        }
-        return ret;
-    }
-
-    @Specialization(guards = {"!isZeroLength", "preserveNames", "!preserveDimensions"})
-    protected RStringVector doLogicalVectorNames(VirtualFrame frame, RLogicalVector vector) {
-        String[] result = dataFromLogical(frame, vector);
-        RStringVector ret = RDataFactory.createStringVector(result, RDataFactory.COMPLETE_VECTOR, vector.getNames());
-        if (isAttrPreservation()) {
-            ret.copyRegAttributesFrom(vector);
-        }
-        return ret;
-    }
-
-    @Specialization(guards = {"!isZeroLength", "preserveNames", "preserveDimensions"})
-    protected RStringVector doLogicalVectorDimsNames(VirtualFrame frame, RLogicalVector vector) {
-        String[] result = dataFromLogical(frame, vector);
-        RStringVector ret = RDataFactory.createStringVector(result, RDataFactory.COMPLETE_VECTOR, vector.getDimensions(), vector.getNames());
-        if (isAttrPreservation()) {
-            ret.copyRegAttributesFrom(vector);
-        }
-        return ret;
-    }
-
-    @Specialization(guards = {"!isZeroLength", "!preserveNames", "!preserveDimensions"})
-    protected RStringVector doLogicalVector(VirtualFrame frame, RLogicalVector vector) {
-        String[] result = dataFromLogical(frame, vector);
-        RStringVector ret = RDataFactory.createStringVector(result, RDataFactory.COMPLETE_VECTOR);
-        if (isAttrPreservation()) {
-            ret.copyRegAttributesFrom(vector);
-        }
-        return ret;
-    }
-
-    @Specialization(guards = {"!isZeroLength", "!preserveNames", "preserveDimensions"})
-    protected RStringVector doComplexVectorDims(VirtualFrame frame, RComplexVector vector) {
-        String[] result = dataFromComplex(frame, vector);
-        RStringVector ret = RDataFactory.createStringVector(result, RDataFactory.COMPLETE_VECTOR, vector.getDimensions());
-        if (isAttrPreservation()) {
-            ret.copyRegAttributesFrom(vector);
-        }
-        return ret;
-    }
-
-    @Specialization(guards = {"!isZeroLength", "preserveNames", "!preserveDimensions"})
-    protected RStringVector doComplexVectorNames(VirtualFrame frame, RComplexVector vector) {
-        String[] result = dataFromComplex(frame, vector);
-        RStringVector ret = RDataFactory.createStringVector(result, RDataFactory.COMPLETE_VECTOR, vector.getNames());
-        if (isAttrPreservation()) {
-            ret.copyRegAttributesFrom(vector);
-        }
-        return ret;
-    }
-
-    @Specialization(guards = {"!isZeroLength", "preserveNames", "preserveDimensions"})
-    protected RStringVector doComplexVectorDimsNames(VirtualFrame frame, RComplexVector vector) {
-        String[] result = dataFromComplex(frame, vector);
-        RStringVector ret = RDataFactory.createStringVector(result, RDataFactory.COMPLETE_VECTOR, vector.getDimensions(), vector.getNames());
-        if (isAttrPreservation()) {
-            ret.copyRegAttributesFrom(vector);
-        }
-        return ret;
-    }
-
-    @Specialization(guards = {"!isZeroLength", "!preserveNames", "!preserveDimensions"})
-    protected RStringVector doComplexVector(VirtualFrame frame, RComplexVector vector) {
-        String[] result = dataFromComplex(frame, vector);
-        RStringVector ret = RDataFactory.createStringVector(result, RDataFactory.COMPLETE_VECTOR);
-        if (isAttrPreservation()) {
-            ret.copyRegAttributesFrom(vector);
-        }
-        return ret;
-    }
-
-    @Specialization(guards = {"!isZeroLength", "!preserveNames", "preserveDimensions"})
-    protected RStringVector doRawVectorDims(VirtualFrame frame, RRawVector vector) {
-        String[] result = dataFromRaw(frame, vector);
-        RStringVector ret = RDataFactory.createStringVector(result, RDataFactory.COMPLETE_VECTOR, vector.getDimensions());
-        if (isAttrPreservation()) {
-            ret.copyRegAttributesFrom(vector);
-        }
-        return ret;
-    }
-
-    @Specialization(guards = {"!isZeroLength", "preserveNames", "!preserveDimensions"})
-    protected RStringVector doRawVectorNames(VirtualFrame frame, RRawVector vector) {
-        String[] result = dataFromRaw(frame, vector);
-        RStringVector ret = RDataFactory.createStringVector(result, RDataFactory.COMPLETE_VECTOR, vector.getNames());
-        if (isAttrPreservation()) {
-            ret.copyRegAttributesFrom(vector);
-        }
-        return ret;
-    }
-
-    @Specialization(guards = {"!isZeroLength", "preserveNames", "preserveDimensions"})
-    protected RStringVector doRawVectorDimsNames(VirtualFrame frame, RRawVector vector) {
-        String[] result = dataFromRaw(frame, vector);
-        RStringVector ret = RDataFactory.createStringVector(result, RDataFactory.COMPLETE_VECTOR, vector.getDimensions(), vector.getNames());
-        if (isAttrPreservation()) {
-            ret.copyRegAttributesFrom(vector);
-        }
-        return ret;
-    }
-
-    @Specialization(guards = {"!isZeroLength", "!preserveNames", "!preserveDimensions"})
-    protected RStringVector doRawVector(VirtualFrame frame, RRawVector vector) {
-        String[] result = dataFromRaw(frame, vector);
-        RStringVector ret = RDataFactory.createStringVector(result, RDataFactory.COMPLETE_VECTOR);
-        if (isAttrPreservation()) {
-            ret.copyRegAttributesFrom(vector);
-        }
-        return ret;
+    protected RStringVector doComplexVector(VirtualFrame frame, RComplexVector operand) {
+        return createResultVector(operand, index -> toString.executeString(frame, operand.getDataAt(index)));
     }
 
-    @Specialization(guards = {"!isZeroLength", "!preserveNames", "preserveDimensions"})
-    protected RStringVector doListDims(VirtualFrame frame, RList list) {
-        String[] result = dataFromList(frame, list);
-        RStringVector ret = RDataFactory.createStringVector(result, RDataFactory.COMPLETE_VECTOR, list.getDimensions());
-        if (isAttrPreservation()) {
-            ret.copyRegAttributesFrom(list);
-        }
-        return ret;
-    }
-
-    @Specialization(guards = {"!isZeroLength", "preserveNames", "!preserveDimensions"})
-    protected RStringVector doListNames(VirtualFrame frame, RList list) {
-        String[] result = dataFromList(frame, list);
-        RStringVector ret = RDataFactory.createStringVector(result, RDataFactory.COMPLETE_VECTOR, list.getNames());
-        if (isAttrPreservation()) {
-            ret.copyRegAttributesFrom(list);
-        }
-        return ret;
-    }
-
-    @Specialization(guards = {"!isZeroLength", "preserveNames", "preserveDimensions"})
-    protected RStringVector doListDimsNames(VirtualFrame frame, RList list) {
-        String[] result = dataFromList(frame, list);
-        RStringVector ret = RDataFactory.createStringVector(result, RDataFactory.COMPLETE_VECTOR, list.getDimensions(), list.getNames());
-        if (isAttrPreservation()) {
-            ret.copyRegAttributesFrom(list);
-        }
-        return ret;
+    @Specialization(guards = "!isZeroLength")
+    protected RStringVector doRawVector(VirtualFrame frame, RRawVector operand) {
+        return createResultVector(operand, index -> toString.executeString(frame, operand.getDataAt(index)));
     }
 
-    @Specialization(guards = {"!isZeroLength", "!preserveNames", "!preserveDimensions"})
-    protected RStringVector doList(VirtualFrame frame, RList list) {
-        String[] result = dataFromList(frame, list);
-        RStringVector ret = RDataFactory.createStringVector(result, RDataFactory.COMPLETE_VECTOR);
-        if (isAttrPreservation()) {
-            ret.copyRegAttributesFrom(list);
-        }
-        return ret;
+    @Specialization(guards = "!isZeroLength")
+    protected RStringVector doList(VirtualFrame frame, RList operand) {
+        return createResultVector(operand, index -> toString.executeString(frame, operand.getDataAt(index)));
     }
 
     @Specialization
@@ -303,50 +131,7 @@ public abstract class CastStringNode extends CastNode {
         return s.getName();
     }
 
-    private RStringVector performAbstractIntVector(VirtualFrame frame, RAbstractIntVector vector) {
-        int length = vector.getLength();
-        String[] result = new String[length];
-        for (int i = 0; i < length; i++) {
-            result[i] = toString.executeString(frame, vector.getDataAt(i));
-        }
-        RStringVector ret;
-        if (preserveDimensions()) {
-            ret = RDataFactory.createStringVector(result, RDataFactory.COMPLETE_VECTOR, vector.getDimensions());
-        } else if (preserveNames()) {
-            ret = RDataFactory.createStringVector(result, RDataFactory.COMPLETE_VECTOR, vector.getNames());
-        } else {
-            ret = RDataFactory.createStringVector(result, RDataFactory.COMPLETE_VECTOR);
-        }
-        if (isAttrPreservation()) {
-            ret.copyRegAttributesFrom(vector);
-        }
-        return ret;
-    }
-
-    private RStringVector performAbstractDoubleVector(VirtualFrame frame, RAbstractDoubleVector vector) {
-        int length = vector.getLength();
-        String[] result = new String[length];
-        for (int i = 0; i < length; i++) {
-            result[i] = toString.executeString(frame, vector.getDataAt(i));
-        }
-        RStringVector ret;
-        if (preserveDimensions() && preserveNames()) {
-            ret = RDataFactory.createStringVector(result, RDataFactory.COMPLETE_VECTOR, vector.getDimensions(), vector.getNames());
-        } else if (preserveDimensions()) {
-            ret = RDataFactory.createStringVector(result, RDataFactory.COMPLETE_VECTOR, vector.getDimensions());
-        } else if (preserveNames()) {
-            ret = RDataFactory.createStringVector(result, RDataFactory.COMPLETE_VECTOR, vector.getNames());
-        } else {
-            ret = RDataFactory.createStringVector(result, RDataFactory.COMPLETE_VECTOR);
-        }
-        if (isAttrPreservation()) {
-            ret.copyRegAttributesFrom(vector);
-        }
-        return ret;
-    }
-
     protected boolean isZeroLength(RAbstractVector vector) {
         return vector.getLength() == 0;
     }
-
 }
diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastSymbolNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastSymbolNode.java
index d2d610b8804ee093be953c9e03d1a7b18a453513..e85dc40662ae128ec3eb11a52e7955bdc114c287 100644
--- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastSymbolNode.java
+++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastSymbolNode.java
@@ -28,16 +28,14 @@ import com.oracle.truffle.api.frame.*;
 import com.oracle.truffle.r.runtime.*;
 import com.oracle.truffle.r.runtime.data.*;
 
-@NodeField(name = "emptyVectorConvertedToNull", type = boolean.class)
 public abstract class CastSymbolNode extends CastNode {
 
     @Child private ToStringNode toString = ToStringNodeFactory.create(null, true, ToStringNode.DEFAULT_SEPARATOR, false);
 
     public abstract Object executeSymbol(VirtualFrame frame, Object o);
 
-    @SuppressWarnings("unused")
     @Specialization
-    protected RSymbol doNull(RNull value) {
+    protected RSymbol doNull(@SuppressWarnings("unused") RNull value) {
         throw RError.error(getEncapsulatingSourceSection(), RError.Message.INVALID_TYPE_LENGTH, "symbol", 0);
     }
 
@@ -62,7 +60,7 @@ public abstract class CastSymbolNode extends CastNode {
     }
 
     @Specialization
-    protected RSymbol doStringVector(@SuppressWarnings("unused") VirtualFrame frame, RStringVector value) {
+    protected RSymbol doStringVector(RStringVector value) {
         // Only element 0 interpreted
         return doString(value.getDataAt(0));
     }
@@ -86,5 +84,4 @@ public abstract class CastSymbolNode extends CastNode {
     private static RSymbol backQuote(String s) {
         return RDataFactory.createSymbol("`" + s + "`");
     }
-
 }
diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/ConvertBooleanNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/ConvertBooleanNode.java
index 62752158abcdedcd75b8b2f736a31f29e8f29b2b..bfb6bbe3f0cdd36fd158bc73bc064e00ad6d6de9 100644
--- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/ConvertBooleanNode.java
+++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/ConvertBooleanNode.java
@@ -33,7 +33,9 @@ import com.oracle.truffle.r.runtime.ops.na.*;
 
 public abstract class ConvertBooleanNode extends UnaryNode {
 
-    private final NACheck check = NACheck.create();
+    private final NAProfile naProfile = NAProfile.create();
+    private final BranchProfile invalidElementCountBranch = BranchProfile.create();
+    private final BranchProfile errorBranch = BranchProfile.create();
 
     @Override
     public abstract byte executeByte(VirtualFrame frame);
@@ -41,47 +43,41 @@ public abstract class ConvertBooleanNode extends UnaryNode {
     public abstract byte executeByte(VirtualFrame frame, Object operandValue);
 
     @Specialization
-    protected byte doLogical(byte value) {
-        check.enable(value);
-        if (check.check(value)) {
-            throw RError.error(getEncapsulatingSourceSection(), RError.Message.NA_UNEXP);
+    protected byte doInt(int value) {
+        if (naProfile.isNA(value)) {
+            throw RError.error(getEncapsulatingSourceSection(), RError.Message.ARGUMENT_NOT_INTERPRETABLE_LOGICAL);
         }
-        return value;
+        return RRuntime.int2logicalNoCheck(value);
     }
 
     @Specialization
-    protected byte doInt(int value) {
-        check.enable(value);
-        if (check.check(value)) {
+    protected byte doDouble(double value) {
+        if (naProfile.isNA(value)) {
             throw RError.error(getEncapsulatingSourceSection(), RError.Message.ARGUMENT_NOT_INTERPRETABLE_LOGICAL);
         }
-        return RRuntime.asLogical(value != 0);
+        return RRuntime.double2logicalNoCheck(value);
     }
 
     @Specialization
-    protected byte doDouble(double value) {
-        check.enable(value);
-        if (check.check(value)) {
-            throw RError.error(getEncapsulatingSourceSection(), RError.Message.ARGUMENT_NOT_INTERPRETABLE_LOGICAL);
+    protected byte doLogical(byte value) {
+        if (naProfile.isNA(value)) {
+            throw RError.error(getEncapsulatingSourceSection(), RError.Message.NA_UNEXP);
         }
-        return RRuntime.asLogical(value != 0D);
+        return value;
     }
 
     @Specialization
     protected byte doComplex(RComplex value) {
-        check.enable(value);
-        if (check.check(value)) {
+        if (naProfile.isNA(value)) {
             throw RError.error(getEncapsulatingSourceSection(), RError.Message.ARGUMENT_NOT_INTERPRETABLE_LOGICAL);
         }
-        return RRuntime.asLogical(!value.isZero());
+        return RRuntime.complex2logicalNoCheck(value);
     }
 
     @Specialization
     protected byte doString(String value) {
-        check.enable(value);
-        byte logicalValue = check.convertStringToLogical(value);
-        check.enable(logicalValue);
-        if (check.check(logicalValue)) {
+        byte logicalValue = RRuntime.string2logicalNoCheck(value);
+        if (naProfile.isNA(logicalValue)) {
             throw RError.error(getEncapsulatingSourceSection(), RError.Message.ARGUMENT_NOT_INTERPRETABLE_LOGICAL);
         }
         return logicalValue;
@@ -89,113 +85,55 @@ public abstract class ConvertBooleanNode extends UnaryNode {
 
     @Specialization
     protected byte doRaw(RRaw value) {
-        return RRuntime.asLogical(value.getValue() != 0);
+        return RRuntime.raw2logical(value);
     }
 
-    @Specialization
-    protected byte doIntSequence(RIntSequence value) {
-        if (value.getLength() > 1) {
-            moreThanOneElem.enter();
-            RError.warning(this.getEncapsulatingSourceSection(), RError.Message.LENGTH_GT_1);
+    private void checkLength(RAbstractVector value) {
+        if (value.getLength() != 1) {
+            invalidElementCountBranch.enter();
+            if (value.getLength() == 0) {
+                errorBranch.enter();
+                throw RError.error(getEncapsulatingSourceSection(), RError.Message.LENGTH_ZERO);
+            } else {
+                RError.warning(getEncapsulatingSourceSection(), RError.Message.LENGTH_GT_1);
+            }
         }
-        return RRuntime.asLogical(value.getStart() != 0);
     }
 
     @Specialization
-    protected byte doDoubleSequence(RDoubleSequence value) {
-        if (value.getLength() > 1) {
-            moreThanOneElem.enter();
-            RError.warning(this.getEncapsulatingSourceSection(), RError.Message.LENGTH_GT_1);
-        }
-        return RRuntime.asLogical(value.getStart() != 0D);
-    }
-
-    @SuppressWarnings("unused")
-    @Specialization(guards = "isEmpty")
-    protected byte doEmptyVector(RAbstractVector value) {
-        throw RError.error(this.getEncapsulatingSourceSection(), RError.Message.LENGTH_ZERO);
+    protected byte doIntVector(RAbstractIntVector value) {
+        checkLength(value);
+        return doInt(value.getDataAt(0));
     }
 
-    private final BranchProfile moreThanOneElem = BranchProfile.create();
-
-    @Specialization(guards = "!isEmpty")
-    protected byte doIntVector(RIntVector value) {
-        if (value.getLength() > 1) {
-            moreThanOneElem.enter();
-            RError.warning(this.getEncapsulatingSourceSection(), RError.Message.LENGTH_GT_1);
-        }
-        check.enable(value);
-        if (check.check(value.getDataAt(0))) {
-            throw RError.error(getEncapsulatingSourceSection(), RError.Message.ARGUMENT_NOT_INTERPRETABLE_LOGICAL);
-        }
-        return RRuntime.asLogical(value.getDataAt(0) != 0);
-    }
-
-    @Specialization(guards = "!isEmpty")
-    protected byte doDoubleVector(RDoubleVector value) {
-        if (value.getLength() > 1) {
-            moreThanOneElem.enter();
-            RError.warning(this.getEncapsulatingSourceSection(), RError.Message.LENGTH_GT_1);
-        }
-        check.enable(value);
-        if (check.check(value.getDataAt(0))) {
-            throw RError.error(getEncapsulatingSourceSection(), RError.Message.ARGUMENT_NOT_INTERPRETABLE_LOGICAL);
-        }
-        return RRuntime.asLogical(value.getDataAt(0) != 0D);
+    @Specialization
+    protected byte doDoubleVector(RAbstractDoubleVector value) {
+        checkLength(value);
+        return doDouble(value.getDataAt(0));
     }
 
-    @Specialization(guards = "!isEmpty")
+    @Specialization
     protected byte doLogicalVector(RLogicalVector value) {
-        if (value.getLength() > 1) {
-            moreThanOneElem.enter();
-            RError.warning(this.getEncapsulatingSourceSection(), RError.Message.LENGTH_GT_1);
-        }
-        check.enable(value);
-        if (check.check(value.getDataAt(0))) {
-            throw RError.error(getEncapsulatingSourceSection(), RError.Message.NA_UNEXP);
-        }
-        return RRuntime.asLogical(value.getDataAt(0) != RRuntime.LOGICAL_FALSE);
+        checkLength(value);
+        return doLogical(value.getDataAt(0));
     }
 
-    @Specialization(guards = "!isEmpty")
+    @Specialization
     protected byte doComplexVector(RComplexVector value) {
-        if (value.getLength() > 1) {
-            moreThanOneElem.enter();
-            RError.warning(this.getEncapsulatingSourceSection(), RError.Message.LENGTH_GT_1);
-        }
-        check.enable(value);
-        if (check.check(value.getDataAt(0))) {
-            throw RError.error(getEncapsulatingSourceSection(), RError.Message.ARGUMENT_NOT_INTERPRETABLE_LOGICAL);
-        }
-        return RRuntime.asLogical(!value.getDataAt(0).isZero());
+        checkLength(value);
+        return doComplex(value.getDataAt(0));
     }
 
-    @Specialization(guards = "!isEmpty")
-    protected byte doRawVector(RRawVector value) {
-        if (value.getLength() > 1) {
-            moreThanOneElem.enter();
-            RError.warning(this.getEncapsulatingSourceSection(), RError.Message.LENGTH_GT_1);
-        }
-        return RRuntime.asLogical(value.getDataAt(0).getValue() != 0);
-    }
-
-    @Specialization(guards = "!isEmpty")
+    @Specialization
     protected byte doStringVector(RStringVector value) {
-        if (value.getLength() > 1) {
-            moreThanOneElem.enter();
-            RError.warning(this.getEncapsulatingSourceSection(), RError.Message.LENGTH_GT_1);
-        }
-        check.enable(value);
-        byte logicalValue = check.convertStringToLogical(value.getDataAt(0));
-        check.enable(logicalValue);
-        if (check.check(logicalValue)) {
-            throw RError.error(getEncapsulatingSourceSection(), RError.Message.ARGUMENT_NOT_INTERPRETABLE_LOGICAL);
-        }
-        return logicalValue;
+        checkLength(value);
+        return doString(value.getDataAt(0));
     }
 
-    protected boolean isEmpty(RAbstractVector vector) {
-        return vector.getLength() == 0;
+    @Specialization
+    protected byte doRawVector(RRawVector value) {
+        checkLength(value);
+        return doRaw(value.getDataAt(0));
     }
 
     public static ConvertBooleanNode create(RNode node) {