diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Rm.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Rm.java
index 1b50f6676904005ab78f6200a0bf3b747ca82ea6..f7433458c16cbc4acddd19d78abe95026e7e0015 100644
--- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Rm.java
+++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Rm.java
@@ -33,19 +33,17 @@ import static com.oracle.truffle.r.runtime.builtins.RBehavior.COMPLEX;
 import static com.oracle.truffle.r.runtime.builtins.RBuiltinKind.INTERNAL;
 
 import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
+import com.oracle.truffle.api.dsl.Cached;
 import com.oracle.truffle.api.dsl.Specialization;
-import com.oracle.truffle.api.frame.Frame;
-import com.oracle.truffle.api.frame.FrameSlot;
-import com.oracle.truffle.api.profiles.BranchProfile;
 import com.oracle.truffle.r.nodes.builtin.RBuiltinNode;
-import com.oracle.truffle.r.runtime.RArguments;
 import com.oracle.truffle.r.runtime.RError;
 import com.oracle.truffle.r.runtime.builtins.RBuiltin;
 import com.oracle.truffle.r.runtime.data.RNull;
 import com.oracle.truffle.r.runtime.data.model.RAbstractStringVector;
+import com.oracle.truffle.r.runtime.data.nodes.VectorAccess;
+import com.oracle.truffle.r.runtime.data.nodes.VectorAccess.SequentialIterator;
 import com.oracle.truffle.r.runtime.env.REnvironment;
 import com.oracle.truffle.r.runtime.env.REnvironment.PutException;
-import com.oracle.truffle.r.runtime.env.frame.FrameSlotChangeMonitor;
 
 /**
  * Note: remove is invoked from builtin wrappers 'rm' and 'remove' that are identical.
@@ -53,8 +51,6 @@ import com.oracle.truffle.r.runtime.env.frame.FrameSlotChangeMonitor;
 @RBuiltin(name = "remove", visibility = OFF, kind = INTERNAL, parameterNames = {"list", "envir", "inherits"}, behavior = COMPLEX)
 public abstract class Rm extends RBuiltinNode.Arg3 {
 
-    private final BranchProfile invalidateProfile = BranchProfile.create();
-
     static {
         Casts casts = new Casts(Rm.class);
         casts.arg("list").mustBe(stringValue(), INVALID_FIRST_ARGUMENT);
@@ -64,36 +60,47 @@ public abstract class Rm extends RBuiltinNode.Arg3 {
 
     @Specialization
     @TruffleBoundary
-    protected Object rm(RAbstractStringVector list, REnvironment envir, @SuppressWarnings("unused") boolean inherits) {
-        try {
-            for (int i = 0; i < list.getLength(); i++) {
-                if (envir == REnvironment.globalEnv()) {
-                    removeFromFrame(envir.getFrame(), list.getDataAt(i));
-                } else {
-                    envir.rm(list.getDataAt(i));
+    protected Object rm(RAbstractStringVector list, REnvironment envir, boolean inherits,
+                    @Cached("createSlowPath(list)") VectorAccess listAccess) {
+        try (SequentialIterator listIter = listAccess.access(list)) {
+            while (listAccess.next(listIter)) {
+                String key = listAccess.getString(listIter);
+                if (!removeFromEnv(envir, key, inherits)) {
+                    warning(RError.Message.UNKNOWN_OBJECT, key);
                 }
             }
+
         } catch (PutException ex) {
-            throw error(ex);
+            error(ex);
         }
+
         return RNull.instance;
     }
 
-    private void removeFromFrame(Frame frame, String x) {
-        // standard case for lookup in current frame
-        Frame frm = frame;
-        FrameSlot fs = frame.getFrameDescriptor().findFrameSlot(x);
-        while (fs == null && frm != null) {
-            frm = RArguments.getEnclosingFrame(frm);
-            if (frm != null) {
-                fs = frm.getFrameDescriptor().findFrameSlot(x);
+    private static boolean removeFromEnv(REnvironment envir, String key, boolean inherits) throws PutException {
+        REnvironment curEnv = envir;
+        while (curEnv != REnvironment.emptyEnv()) {
+            try {
+                curEnv.rm(key);
+                // found and successfully removed
+                return true;
+            } catch (PutException ex) {
+                // 'key' is not in the 'curEnv'
+
+                // Special treatment for base env and base namespace env
+                if (curEnv == REnvironment.baseEnv() || curEnv == REnvironment.baseNamespaceEnv() || curEnv.isLocked()) {
+                    throw ex;
+                }
+
+                if (inherits) {
+                    curEnv = curEnv.getParent();
+                    continue;
+                } else {
+                    return false;
+                }
             }
         }
-        if (fs == null) {
-            warning(RError.Message.UNKNOWN_OBJECT, x);
-        } else {
-            // use null (not an R value) to represent "undefined"
-            FrameSlotChangeMonitor.setObjectAndInvalidate(frm, fs, null, false, invalidateProfile);
-        }
+        // not found in any environment
+        return false;
     }
 }
diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/BaseWriteVariableNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/BaseWriteVariableNode.java
index 4803d069f7f944137fb0b2b03e91f2e4b72cd5f2..6db88a49aa04b81d8f6feadfa53be6346c4dfe2e 100644
--- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/BaseWriteVariableNode.java
+++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/BaseWriteVariableNode.java
@@ -192,7 +192,7 @@ abstract class BaseWriteVariableNode extends WriteVariableNode {
             try {
                 return writeActiveBinding.execute(execFrame, binding.getFunction(), new RArgsValuesAndNames(new Object[]{value}, ArgumentsSignature.empty(1)));
             } finally {
-                binding.setInitialized();
+                binding.setInitialized(true);
             }
         } else {
             Object newValue = shareObjectValue(lookupFrame, frameSlot, storedObjectProfile.profile(value), mode, false);
diff --git a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/env/frame/ActiveBinding.java b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/env/frame/ActiveBinding.java
index 9e9da206a7f3a3a20a7f4826e3d724fe2c802250..6bf2fce48e6f91ab75dbcc7ca9429e49b6eec38a 100644
--- a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/env/frame/ActiveBinding.java
+++ b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/env/frame/ActiveBinding.java
@@ -41,7 +41,7 @@ public class ActiveBinding implements RTruffleObject {
     private final RType expectedType;
     private final RFunction function;
     private boolean initialized = false;
-    private boolean hidden = false;
+    private final boolean hidden;
 
     public ActiveBinding(RType expectedType, RFunction fun, boolean hidden) {
         this.expectedType = Objects.requireNonNull(expectedType);
@@ -91,8 +91,8 @@ public class ActiveBinding implements RTruffleObject {
         return RContext.getEngine().evalFunction(function, REnvironment.baseEnv().getFrame(), RCaller.createInvalid(null), true, null);
     }
 
-    public void setInitialized() {
-        initialized = true;
+    public void setInitialized(boolean value) {
+        initialized = value;
     }
 
     public static boolean isListed(Object value) {
diff --git a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/env/frame/REnvTruffleFrameAccess.java b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/env/frame/REnvTruffleFrameAccess.java
index 5e0167b6bb22711ae5f1f6023326b8a20a4ab487..a1bab552c1dc30ab68c0bca1e7a14104eb392708 100644
--- a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/env/frame/REnvTruffleFrameAccess.java
+++ b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/env/frame/REnvTruffleFrameAccess.java
@@ -28,6 +28,7 @@ import java.util.HashSet;
 import java.util.Set;
 import java.util.regex.Pattern;
 
+import com.oracle.truffle.api.Assumption;
 import com.oracle.truffle.api.CompilerAsserts;
 import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
 import com.oracle.truffle.api.frame.FrameDescriptor;
@@ -152,6 +153,22 @@ public final class REnvTruffleFrameAccess extends REnvFrameAccess {
             if (slot.getKind() != FrameSlotKind.Object) {
                 slot.setKind(FrameSlotKind.Object);
             }
+
+            Assumption containsNoActiveBindingAssumption = FrameSlotChangeMonitor.getContainsNoActiveBindingAssumption(fd);
+            Object result = null;
+            // special treatment for active binding: call bound function
+            try {
+                if (!containsNoActiveBindingAssumption.isValid() && ActiveBinding.isActiveBinding(result = FrameSlotChangeMonitor.getObject(slot, frame))) {
+                    ActiveBinding binding = (ActiveBinding) result;
+                    if (binding.isHidden()) {
+                        binding.setInitialized(false);
+                        return;
+                    }
+                }
+            } catch (FrameSlotTypeException e) {
+                // ignore
+            }
+
             FrameSlotChangeMonitor.setObjectAndInvalidate(frame, slot, null, false, null);
         }
     }
diff --git a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/rng/RRNG.java b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/rng/RRNG.java
index 9457756bd5acdff9e31ebeca1590012f138b3db0..77a6da31234353bca8647eb6c6eb9875db85b30a 100644
--- a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/rng/RRNG.java
+++ b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/rng/RRNG.java
@@ -197,11 +197,9 @@ public class RRNG {
         }
 
         public void setCurrentSeeds(Object seeds) {
-            if (this.currentSeeds == null) {
-                ActiveBinding activeBinding = dotRandomSeedBinding.get();
-                if (activeBinding != null) {
-                    activeBinding.setInitialized();
-                }
+            ActiveBinding activeBinding = dotRandomSeedBinding.get();
+            if (activeBinding != null) {
+                activeBinding.setInitialized(true);
             }
             this.currentSeeds = seeds;
         }
diff --git a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/ExpectedTestOutput.test b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/ExpectedTestOutput.test
index dbd0accdaac4128efde9e05b950f06661f49541f..31b07e1765a1bc1bb3d96297b1d9543bcb95bb48 100644
--- a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/ExpectedTestOutput.test
+++ b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/ExpectedTestOutput.test
@@ -51860,7 +51860,7 @@ integer(0)
 # e <- new.env(); e$a <- 42; rm(list='a', envir=e); e$a
 NULL
 
-##com.oracle.truffle.r.test.builtins.TestBuiltin_rm.basicTests#Output.IgnoreErrorContext#
+##com.oracle.truffle.r.test.builtins.TestBuiltin_rm.basicTests#
 #tmp <- 42; f <- function() rm(list='tmp',inherits=T); f(); tmp
 Error: object 'tmp' not found
 
@@ -51872,6 +51872,73 @@ Error: object 'tmp' not found
 #tmp <- 42; rm(tmp); tmp
 Error: object 'tmp' not found
 
+##com.oracle.truffle.r.test.builtins.TestBuiltin_rm.basicTests#
+#{ e <- new.env(); e$a <- 1234L; lockBinding('a', e); rm(list='a', envir=e); ls(e) }
+character(0)
+
+##com.oracle.truffle.r.test.builtins.TestBuiltin_rm.basicTests#
+#{ e <- new.env(); e$a <- 1234L; lockEnvironment(e); rm(list='a', envir=e); ls(e) }
+Error in rm(list = "a", envir = e) :
+  cannot remove bindings from a locked environment
+
+##com.oracle.truffle.r.test.builtins.TestBuiltin_rm.basicTests#
+#{ e <- new.env(); e$a <- 1234L; rm(list=c('c', 'a'), envir=e); ls(e) }
+character(0)
+Warning message:
+In rm(list = c("c", "a"), envir = e) : object 'c' not found
+
+##com.oracle.truffle.r.test.builtins.TestBuiltin_rm.basicTests#
+#{ e <- new.env(parent=baseenv()); e$a <- 1234L; rm(c('c', 'a'), envir=e, inherits=T); ls(e) }
+Error in rm(c("c", "a"), envir = e, inherits = T) :
+  ... must contain names or character strings
+
+##com.oracle.truffle.r.test.builtins.TestBuiltin_rm.basicTests#
+#{ e <- new.env(parent=baseenv()); rm('c', envir=e, inherits=T) }
+Error in rm("c", envir = e, inherits = T) :
+  cannot remove variables from the base environment
+
+##com.oracle.truffle.r.test.builtins.TestBuiltin_rm.basicTests#
+#{ env0 <- new.env(); env0$a <- 123L; env1 <- new.env(parent=env0); env1$b <- 456L; rm('a', envir=env1, inherits=F); lapply(c(env0, env1), function(x) ls(x)) }
+[[1]]
+[1] "a"
+
+[[2]]
+[1] "b"
+
+Warning message:
+In rm("a", envir = env1, inherits = F) : object 'a' not found
+
+##com.oracle.truffle.r.test.builtins.TestBuiltin_rm.basicTests#
+#{ env0 <- new.env(); env0$a <- 123L; env1 <- new.env(parent=env0); env1$b <- 456L; rm('a', envir=env1, inherits=T); lapply(c(env0, env1), function(x) ls(x)) }
+[[1]]
+character(0)
+
+[[2]]
+[1] "b"
+
+
+##com.oracle.truffle.r.test.builtins.TestBuiltin_rm.basicTests#
+#{ env0 <- new.env(); env0$b <- 123L; env1 <- new.env(parent=env0); env1$b <- 456L; rm('b', envir=env1, inherits=F); lapply(c(env0, env1), function(x) ls(x)) }
+[[1]]
+[1] "b"
+
+[[2]]
+character(0)
+
+
+##com.oracle.truffle.r.test.builtins.TestBuiltin_rm.basicTests#
+#{ rm(list='a', envir=emptyenv()) }
+Warning message:
+In rm(list = "a", envir = emptyenv()) : object 'a' not found
+
+##com.oracle.truffle.r.test.builtins.TestBuiltin_rm.basicTests#
+#{ rm(list=ls(baseenv(), all.names=TRUE), envir=baseenv()) }
+Error in rm(list = ls(baseenv(), all.names = TRUE), envir = baseenv()) :
+  cannot remove variables from the base environment
+
+##com.oracle.truffle.r.test.builtins.TestBuiltin_rm.basicTests#
+#{ rm(list=ls(emptyenv()), envir=emptyenv()) }
+
 ##com.oracle.truffle.r.test.builtins.TestBuiltin_rm.testArgsCasting#
 #.Internal(remove(list=33, environment(), F))
 Error: invalid first argument
@@ -167682,3 +167749,223 @@ In runif(3) :
 #invisible(runif(5)); RNGkind('Marsaglia-Multicarry'); set.seed(2); runif(5);
 [1] 0.8431527 0.5749091 0.1531976 0.3460321 0.2313936
 
+##com.oracle.truffle.r.test.rng.TestRRNG.testRemoveSeed#Output.IgnoreErrorContext#
+#{ rm(list = ls(envir = .GlobalEnv, all.names = TRUE)); .Random.seed }
+Error: object '.Random.seed' not found
+
+##com.oracle.truffle.r.test.rng.TestRRNG.testRemoveSeed#
+#{ rm(list = ls(envir = .GlobalEnv, all.names = TRUE)); set.seed(1); .Random.seed }
+  [1]         403         624  -169270483  -442010614  -603558397  -222347416
+  [7]  1489374793   865871222  1734802815    98005428   268448037    63650722
+ [13] -1754793285 -2135275840  -779982911  -864886130  1880007095   463784588
+ [19]  1271615005  1390544442  -544608653  -251475688  -326549447 -1570483546
+ [25]  1965989103  -784675228  1458985493  2146317266 -1103943381   289023600
+ [31]  -436963407   109630910    69979943  1606475068  1441346829  -662821782
+ [37]  -381252893  -311574840  1918496297   289721302   507975775  -209037548
+ [43]  1665646341  -466864126   776139675  1704391200  -162823263 -1815571218
+ [49]   471685271  1503042540    -9316355   773770906  1304642387  1931157624
+ [55] -1378412519   965775622    19361743  1561398212  1879269365  1049118770
+ [61]  1191074315   508275152 -1006204015  -639295458  1060781575  -724498788
+ [67]   257177325 -1004075830   323426243   602271272  1516224009  -111500746
+ [73]  -368663745  1624894580 -1946665755  -305830814  -779330437  1251167616
+ [79] -2140893311  2068936526  1520009079  -673505972   406802909  -205928710
+ [85]  1641613363  1751721944   454221817 -2089418906  1121694383  1689254180
+ [91] -1984604715  -781808494  1892940523   409525552 -1134260367 -2025809282
+ [97]   823270631  1407180796  1755457741   783947050  -213904221   536857992
+[103]  1791983081 -1888114538 -2091016673 -1860292140  -276190523  2041495746
+[109]   293352795 -2071504672  1489341281 -1448769106  -885320105  -724939092
+[115]   -89408579   801828698 -2096939757  1355079480 -1942710311 -1985176122
+[121] -1593612913 -2123393404  -410764363  1470169330  1508641739   174702736
+[127]  1980138321  1530086622  -412390457   826632540  1682639533   709842314
+[133]  1047101827  -678208280  2040606153 -1020403978  2130970879  -206624972
+[139]   796133541  -318747358   441089595  1414206528  1684436801   291294222
+[145]  1773804855   985411596  -953215587   -93698118   880402931   403064472
+[151]  -717996103 -1580438490  1582729327  2024268772   149426581   -61889198
+[157] -1132557141  -349809680 -1813747919  1851072318  -872535385  1834590908
+[163] -1060709235  1425982954  -973382045 -1401381816  -657666647  -803519146
+[169]  1303503839   602197140   690968197 -1194194558 -1271974117  -424247392
+[175] -2076224735  1896824430 -1915841513 -1610038932  1514233725  -139472870
+[181]   359986899   369450488  1175050137  1835887238 -1718805681  1001447748
+[187] -1453795467  -158697038  -289178229 -1653172400 -1258931439 -1522652770
+[193] -1534961273 -1267430372  -124936595  -656382390  1999481667  1820822440
+[199]  1447714185  1037425590  1008676543  -384359948  -164391835  1513879010
+[205]  1130520571  1419877120 -1790435583  1398071502  -349144329  1191707340
+[211]  1281005917  1471383674  -517178445   244983128 -1431478407  -634939162
+[217]  1298079279  -404582748 -1068593835 -1989575150  -487399829  -265123152
+[223]  1949564657 -1333369858 -1833961369  1592665468  1108824141  1812739754
+[229]  1530423331  1368926984  1007803753  -537550314  1929636255   916334420
+[235]  -336018875  1515590210  -937690917 -1562089888  1886968545   247837486
+[241] -1852321321   504493100  -235748547  -695373606  1859678355   832347320
+[247]  1259788121   563279686  1350865167  -963318780 -2126433483    67416690
+[253]   658812747 -1640878576  1754641105   214290014   339674951  1897819868
+[259] -1881411027  1352283914 -1756130045    25328232  1343966537  -703424394
+[265]  -149416833   735173812 -1678319579  1312317090  -560725573 -1034493504
+[271]  -355891519  -973490802  -323184457 -1082223220  1535237405 -1135244998
+[277] -1313811085   451200024  -348242119  -918059610  1437955055  1293941092
+[283]  1537788181 -1049356590  -437194709  1313702256   622024369    43280574
+[289]    48727591 -1688377284 -1873574899  1419929450  1823945187 -1910605368
+[295]  -731992791 -1950040362 -1458327713   336216596  -744100347  -688203006
+[301] -1090356581 -1882125024  -718134623  1737025518 -1000943721  1906697964
+[307]  1434445565  -584855142 -1192383917  -766862472  -887384295 -1562557434
+[313]  -341195057   484161220   -84062475   684698418  -449863413 -1822653232
+[319]   950332049 -1500892386 -1805552377   973279644 -1376385555  -767768630
+[325]   949698243  1967401256 -2032927479 -1197206218  1169078847  1721718644
+[331] -1669469211 -1581938846  1033855867  -735385472   -55923071 -1374991794
+[337]  1008629367   652208204  1751441629 -1726985734 -1345917133  -878304552
+[343] -1499013383  -873713050  2098825647    52438052  1186383061 -1389400174
+[349] -2026323477  -331925456   776105585  -650171010  1516557287  1432840956
+[355]   255555533 -1350477782  1949809571 -1597273976 -1586283287  1615371158
+[361]  1705063711  -957801260  1006033349  1736467394  -895304613  1144812512
+[367]   707471969   538500270  -741634729  2105842092  -660026691  -600640934
+[373]  -579558381  -422618568 -1244129575 -1374924602  1354546319  -112901756
+[379]  1649224373  -844405774  -901492021 -1011508336 -1931222447  1196120030
+[385]  1118413511 -1578994596 -1768171091  1585977482 -1262180221  1720489960
+[391]  -634098487  -766881290  2107842559    71275060   864597925  -311201758
+[397]  1917093179 -2132955328   581670465   273260302  1729500215 -1075053812
+[403] -1497127779   514050746 -1523660557  1872642456 -1398325575   -19554522
+[409] -1991549073   614665956 -1388805995   358320210  1217024939  1890561776
+[415]  -679393743  1766240830 -1763188313  2144087484  -493933683  -580318998
+[421] -1418066589 -2007017656  1661963433 -1438566314  -563316001   435861396
+[427]  1084982661    78032002  -591610341   384211616 -1490816479 -1657433746
+[433]   766905111  -462549908 -1892848003  1685771034 -2043847213   501930232
+[439] -1156819303 -1075831418   628978255  -695104444 -1024407947   458742962
+[445]   943899787   905802320 -1928160751 -2083963746   -52981625   -75720932
+[451]  1301114221 -1237571254   630182467   874235560  -369320823  -809152842
+[457] -1263188545   796036340  1557611365 -1976428318  1313040123  2133800448
+[463]  1955347969 -1317751858 -1151110665 -1922904628   173942877  1037044602
+[469]   464020147   361570392 -1929421191  1053019110      718127 -1939293788
+[475]  2062416981 -2101845742  1806017899  1115088304   680517105 -1486162178
+[481]  1982902119  -850677636  -301031603   -15107670   205393699    60417544
+[487] -1728865175  1986958614   154501279 -1744891308 -1115426491  1731048770
+[493] -1492090917   512721248  1138522593    60753454    -2733865   153239340
+[499]  1288557117  -960793638   483907475  -430106696  1249400409   353937990
+[505]  -810817521  -276785404  -391634379   -90892942  1357575755 -1326184176
+[511]   552669649 -1329340066  1621835335  1502706140 -1769291475  1511586314
+[517]  1690090499   -55462552   367823945   500501366 -1062917249  -755480652
+[523]  -735473883 -1867415134  1666975931  1172274368  -905140799   374114446
+[529]  1187418039  1376018572  1190423581 -1487598534  1559477363 -1942831336
+[535] -1754317255   678869158   655903471  -718199708  1536636949  1040579026
+[541]  -229984469 -2008228752  -382847567  1215036350  1979661607 -1331301572
+[547]  -713436403  -179131798  1346623715 -1858390840 -2099286999 -1852788266
+[553] -1682160033 -1950995180  1312824581   131431938 -1688338021   838281248
+[559] -1206599263   940915438   938231447   241250796 -1521879555   330618010
+[565]  -885780141  1860572792 -1814292967 -1435109626  1963466191  1053974980
+[571]  1597193717   337841714  -167974901 -1151770672  -264287855  -486848994
+[577]  -874206201 -1897849700  -179055379 -1965126966   202073539 -1626446808
+[583]  2110012425  -382105546   926077247 -1718566284   356489957  -642667934
+[589]    55470715   195986304 -1158886015 -2087641778  -687903369 -1869565108
+[595]  -800690211  -873280262  1926288947  1649352152  -608772615   414082406
+[601]    70475951  1505513252 -1158401067  1342460562 -1640396565   686920496
+[607] -1591980687 -1056325506  -736916761  1553659388   -57620787  1624546090
+[613]  -246717789  1879262088   546503657 -2006479210   197184543    -2095148
+[619]  1319110853   526255810  -345685157  -404910368  2072824161  -547868754
+[625] -2085092265  -689249108
+
+##com.oracle.truffle.r.test.rng.TestRRNG.testRemoveSeed#
+#{ set.seed(1); rm(list = ls(envir = .GlobalEnv, all.names = TRUE)); set.seed(2); .Random.seed }
+  [1]         403         624 -1619336578  -714750745  -765106180   158863565
+  [7] -1093870294   242367651 -1691232888 -1538791959   438890646  -141146593
+ [13]   721730004  1779208901   575310018  -949789349   329933024  -952437919
+ [19]  2079445422  1509473879  1815205548    41657277  -401623206  1480549651
+ [25]  1207494456   759627737  -592321082 -1461318257   -59236732  1681990581
+ [31] -1162950414   656225227    30328976 -1151997103  1276218590  1527976903
+ [37]   -99684004  -241896787  -146399862 -1339053693   726230248  -926050871
+ [43]  -754637066  1695592703  2019143476 -1662324571 -2030037726   826648123
+ [49] -1536025536 -1760567487 -1521675250  1556858167  1835513868 -1737294435
+ [55]  -393015366  -985003533  -927052136 -1191532615 -2097826778   218968175
+ [61]  1333029860  -174524011  1774284114  -272386901 -1534108688  1785188145
+ [67]  1238853438  2029638311  1650928316   881116301 -1864790550 -1739225501
+ [73]  -625826744  -676514391 -1223258794  1335004127 -1252830060 -1013301627
+ [79] -1237986942  1983799067   971081632  1427946273  1487111790  -818660329
+ [85]  -805811860  1861830525  -843278310  -338092333    37840376 -2038153319
+ [91] -1363496314   420987727   272722244 -1073889419  1616921010  1377609099
+ [97]  -622616752  1991090961  2103734686  -187563641 -1211755492  1287620205
+[103] -1247859126 -1273244861  2001048488 -1629567607  1307911094    64214719
+[109] -1454790156  -141394843   755219938   -91912197  -321871104  -564558079
+[115]   546121934  1693065975  -700740916   512131421  -945532806 -2027641933
+[121] -1202049704  1641793401  1301864678  -943864273  1547114148 -1159236267
+[127]  -509393390  1080034923  1940099760  2065655537 -1756320770  -262954905
+[133]  1384361340  1891448909   464453290   213553187   987378440  1750746473
+[139]  1798892054 -1433628257  1200926548 -1907643835  1954667074 -1101848357
+[145] -1038651808   197018337  1403124526   765819351  1854503980   -74273987
+[151] -1839056678  1852086419   450929848 -1829159079 -1725415610  -273204977
+[157]  2091742212   432937781  1017281138  1220925259   698824208   246749905
+[163]   338957918  -382292153   922220252 -1829381587    86048522  -949371645
+[169]  -884440472   -99109559   779739254  1215609983 -1349753676   423479333
+[175]   566765218  1574906299 -1433540160 -1304236351   343539086 -1793179465
+[181]   859446668   378914077  1980649786 -1798242957  -978531304  -573266119
+[187]   385928614  1136401391  -419659420  1277800725  -864690478 -1786374101
+[193] -1547269776  -999899471  1017557182 -1187828185   360378428  1642163213
+[199]  1074605930   627136995   979927496 -1777396439    55576278 -1102817441
+[205]   747162132  1709233669  -705780990   291611291 -2096360160 -1562408287
+[211]  1370304494  1661761431  1789226732  1007144701  1187027354   161600083
+[217] -1063869576 -2107244775 -1732604922  1384410831  1014775492   -42846475
+[223]  -130714830  -321337077  1960414416   724325009   624982814 -1778311929
+[229]  1248106908  1207430637   646680522 -2082904381   101855528   -96967415
+[235] -1588372170  -927768001   903995252  2108478437  1041059682 -1391293573
+[241]   342487168 -1433659775  -975990194 -1154998665   119763020  -194983715
+[247]  1687228922  -133228749  2138450648  1017464569  1005419110 -2033700433
+[253]  1250208804   354397397   855193490 -1326061077   465059888  -839002511
+[259] -1365674626   291011559  -569576708  1806786509 -1632362454  1544151971
+[265]   404590728  1619764457   203154326     7986463  1861199060 -1508261435
+[271]   322710466 -1591090085   327121888 -1841261983  -142269266   489239895
+[277] -1492377172 -2078756163 -1147684262 -1487877101  -500997576  1149927129
+[283]  1781635270   658465935   174967172 -1230368075   -69653518  -535463221
+[289]    54174608   869485137 -2058772514   418466503 -2067006372 -1350188627
+[295]   446619786  1126879363  -966615064  2130760905 -1824417290  -632305665
+[301] -1492510156  1621073829   445855778  -102781637   556054336   519372353
+[307]   962193166  1690811447 -1799912692  -341341027 -1007906118  2057236723
+[313]   880167320  1309517497  -652286170  1453459311 -1584425244  1099524245
+[319]  -571649966   342850475 -2110212368  -542855631   568916542  -159151705
+[325] -1627802180 -1309863027 -1738288918  -361484957  -759603384 -2020608855
+[331]  -765689770 -1494408481  -645316716  1790340485   623539330  1600906779
+[337]  -902716768   295787041 -1444292242  -910445801  -964848532  -410691971
+[343] -2119722214  -248412717   776397048 -1993949543 -1974639226   329783887
+[349]  1631720516  1362472565  1884136626 -2076447605  -611681712  1349124625
+[355]  -921729890  1338456199   955129628  -849390227 -1575292598   522058307
+[361]  1794756264   674301065 -1325099338 -1828065857   767890676 -1110037659
+[367]   270131426   369528571 -2021769728   658351617   869071822  -541255177
+[373]  -558475828  -265678755 -2065640582 -1505719629  -210950056 -1580349831
+[379]  -883616794   956931375  -958578268 -1121524651  1444030738    28495211
+[385]  1040706992    18564593 -1957347586   645158759   184629372   408192845
+[391]  1306280362  -899664093   687599112 -1965292439  1657920790 -1487001441
+[397]  -149579180 -1888036539  -998671038   -35149861 -1109227168   415359457
+[403] -1919201746 -1769738025   733595436   973978173  -374326310  1359216531
+[409]   331423672 -1074086311   902689350  2105446415  2075729668 -1730868683
+[415]  1045618034   -83091893  -997650160  1756395985  1163012446  -666704313
+[421]  2039153116  1698998573  1035977226  -244128765   311934312  1435038793
+[427]  1734103926  -928918657 -1261252684  1360033573   929122722 -1824051013
+[433] -1103723328 -1692004927   971821198   969422775 -1478498164 -1247259619
+[439]  1479398458  -994843533 -1961179368 -2019187143 -1353711450  1941893871
+[445]  1429056612   867704853  -467156526  2055200555  1978000496   -98460239
+[451] -1617017922   518710567 -1797031108  1118288653 -1612877206 -1248984861
+[457] -1717224248 -1439706071 -1975780906 -1215500705   307541268 -1340406523
+[463]  1776895490  -295884389  -984469472  1600268705 -2024176914  1900146327
+[469]  -109004308   259120637    74554522  -259507885 -1051582856   415661593
+[475]  1769160454 -1971141169  1418914244   424158709   245945906   642125835
+[481]  1156999120   610709905   248614430   270816263   425895068   -84558611
+[487]   776819402  1407815107 -1677956056   650683401  -485961674   282556735
+[493]  -420263308 -1777433883  1764323938 -1017015685   -66221184   309212545
+[499] -1871092402  1084822903  1928608588 -1344120867 -1366059782  -541524429
+[505] -1975573032   257246713  -506483354   209848495 -1488922844   285023189
+[511] -1863443822  1083617515   278043440  1383576945  -746321794   497496807
+[517]  1868594684 -1801015603   791110442   633178787  1668631432  -448044055
+[523]  -715467114  1295610911   906399700   677572805  1312411330  1653369691
+[529]  2000721632  1564619105  1004828590   129346647   311585964 -1150172739
+[535] -1565803174 -1182911725   632937784 -2092302887  -503493690   544521103
+[541] -1500547964   508494261  1242533618 -1482047029 -1550680432  -347297455
+[547]   -95571234   355172807 -1422588068  -768438099  1954784138 -1606289533
+[553] -1511531800  2075136969   281677046 -1049960705   786859316  -930066779
+[559]  1043487522 -1206537157   935547456  -455729855  1009957390 -2111851721
+[565] -2102178292   311958429 -1194191430 -1055926285  1067074712   144483769
+[571]  2140412454  -921510289  -673791516 -2135566443   623194962  -709410133
+[577] -1261563408  1373474097  1539738942   543768743 -1925693252   840000141
+[583]  1551504362  1420743779 -2060707256   -68242519 -1863421098 -1641825825
+[589]   753609364   336501893  1781208962  1278569755   711835040  1243740449
+[595]   268184686  -945870313   430890860  1372415357  1428069914  1436937427
+[601]  -273130504 -1354416743   472651910  -451645105  -328286396 -1280729739
+[607]   424085426  -520670325  -417508016  -450731759 -1668900962  -988254329
+[613] -2117981668  -289725331  -786254774  -264494781 -1894119000  -201374839
+[619] -1654650442  -266599233 -1217626124  -464135579   255591394  1126405627
+[625]   672651520   706594049
+
diff --git a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/builtins/TestBuiltin_rm.java b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/builtins/TestBuiltin_rm.java
index 15ac77f83a1e5334aa682d597a9de56d8068e55a..ad0df7ee506f4229e1a6640a053779db8725598b 100644
--- a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/builtins/TestBuiltin_rm.java
+++ b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/builtins/TestBuiltin_rm.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -33,7 +33,18 @@ public class TestBuiltin_rm extends TestBase {
         assertEval("tmp <- 42; rm(tmp); tmp");
         assertEval("tmp <- 42; rm(list='tmp'); tmp");
         assertEval(" e <- new.env(); e$a <- 42; rm(list='a', envir=e); e$a");
-        assertEval(Output.IgnoreErrorContext, "tmp <- 42; f <- function() rm(list='tmp',inherits=T); f(); tmp");
+        assertEval("tmp <- 42; f <- function() rm(list='tmp',inherits=T); f(); tmp");
+        assertEval("{ env0 <- new.env(); env0$a <- 123L; env1 <- new.env(parent=env0); env1$b <- 456L; rm('a', envir=env1, inherits=T); lapply(c(env0, env1), function(x) ls(x)) }");
+        assertEval("{ env0 <- new.env(); env0$a <- 123L; env1 <- new.env(parent=env0); env1$b <- 456L; rm('a', envir=env1, inherits=F); lapply(c(env0, env1), function(x) ls(x)) }");
+        assertEval("{ env0 <- new.env(); env0$b <- 123L; env1 <- new.env(parent=env0); env1$b <- 456L; rm('b', envir=env1, inherits=F); lapply(c(env0, env1), function(x) ls(x)) }");
+        assertEval("{ rm(list=ls(baseenv(), all.names=TRUE), envir=baseenv()) }");
+        assertEval("{ e <- new.env(parent=baseenv()); rm('c', envir=e, inherits=T) }");
+        assertEval("{ e <- new.env(parent=baseenv()); e$a <- 1234L; rm(c('c', 'a'), envir=e, inherits=T); ls(e) }");
+        assertEval("{ e <- new.env(); e$a <- 1234L; rm(list=c('c', 'a'), envir=e); ls(e) }");
+        assertEval("{ e <- new.env(); e$a <- 1234L; lockEnvironment(e); rm(list='a', envir=e); ls(e) }");
+        assertEval("{ e <- new.env(); e$a <- 1234L; lockBinding('a', e); rm(list='a', envir=e); ls(e) }");
+        assertEval("{ rm(list='a', envir=emptyenv()) }");
+        assertEval("{ rm(list=ls(emptyenv()), envir=emptyenv()) }");
     }
 
     @Test
diff --git a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/rng/TestRRNG.java b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/rng/TestRRNG.java
index 3fe3ed89c3f0279429824ffb8e57898f20e5b63e..e77ab884d7d9d548bec7f1ce938ee1f4173f44c9 100644
--- a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/rng/TestRRNG.java
+++ b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/rng/TestRRNG.java
@@ -48,4 +48,11 @@ public class TestRRNG extends TestBase {
         assertEval("invisible(runif(1)); length(.Random.seed)");
         assertEval("set.seed(42); .Random.seed");
     }
+
+    @Test
+    public void testRemoveSeed() {
+        assertEval("{ rm(list = ls(envir = .GlobalEnv, all.names = TRUE)); set.seed(1); .Random.seed }");
+        assertEval(Output.IgnoreErrorContext, "{ rm(list = ls(envir = .GlobalEnv, all.names = TRUE)); .Random.seed }");
+        assertEval("{ set.seed(1); rm(list = ls(envir = .GlobalEnv, all.names = TRUE)); set.seed(2); .Random.seed }");
+    }
 }