diff --git a/source/texk/web2c/luatexdir/font/luafont.c b/source/texk/web2c/luatexdir/font/luafont.c
index 6f47d8c71..a16a1b8e5 100644
--- a/source/texk/web2c/luatexdir/font/luafont.c
+++ b/source/texk/web2c/luatexdir/font/luafont.c
@@ -800,7 +800,7 @@ static void read_char_packets(lua_State * L, int *l_fonts, charinfo * co, intern
                     case packet_node_code:
                         append_packet(cmd);
                         lua_rawgeti(L, -2, 2);
-                        n = copy_node_list(nodelist_from_lua(L));
+                        n = copy_node_list(nodelist_from_lua(L, -1));
                         do_store_four(n);
                         lua_pop(L, 1);
                         break;
diff --git a/source/texk/web2c/luatexdir/lua/lnodelib.c b/source/texk/web2c/luatexdir/lua/lnodelib.c
index 368d05f9c..b2adebcbf 100644
--- a/source/texk/web2c/luatexdir/lua/lnodelib.c
+++ b/source/texk/web2c/luatexdir/lua/lnodelib.c
@@ -8881,12 +8881,12 @@ void nodelist_to_lua(lua_State * L, int n)
     lua_nodelib_push(L);
 }
 
-int nodelist_from_lua(lua_State * L)
+int nodelist_from_lua(lua_State * L, int i)
 {
-    if (lua_isnil(L, -1)) {
+    if (lua_isnil(L, i)) {
         return null;
     } else {
-        halfword n= *check_isnode(L, -1);
+        halfword n= *check_isnode(L, i);
         return (n ? n : null);
     }
 }
diff --git a/source/texk/web2c/luatexdir/lua/ltexlib.c b/source/texk/web2c/luatexdir/lua/ltexlib.c
index 11787a33c..40d7dc8ce 100644
--- a/source/texk/web2c/luatexdir/lua/ltexlib.c
+++ b/source/texk/web2c/luatexdir/lua/ltexlib.c
@@ -1398,7 +1398,7 @@ static int vsetbox(lua_State * L, int is_global)
     } else if (t == LUA_TNIL) {
         j = null;
     } else {
-        j = nodelist_from_lua(L);
+        j = nodelist_from_lua(L, -1);
         if (j != null && type(j) != hlist_node && type(j) != vlist_node) {
             luaL_error(L, "setbox: incompatible node type (%s)\n", get_node_name(type(j), subtype(j)));
             return 0;
@@ -3216,7 +3216,13 @@ static int tex_save_box_resource(lua_State * L)
     int margin = pdf_xform_margin;
     boolean immediate = false;
     /* box attributes resources */
-    halfword boxnumber = lua_tointeger(L,1);
+    if (lua_type(L,1) == LUA_TNUMBER) {
+        halfword boxnumber = lua_tointeger(L,1);
+        boxdata = box(boxnumber);
+        box(boxnumber) = null;
+    } else {
+        boxdata = nodelist_from_lua(L,1);
+    }
     if (lua_type(L,2) == LUA_TSTRING) {
         lua_pushvalue(L, 2);
         attributes = luaL_ref(L, LUA_REGISTRYINDEX);
@@ -3235,9 +3241,12 @@ static int tex_save_box_resource(lua_State * L)
         margin = lua_tointeger(L, 6);
     }
     /* more or less same as scanner variant */
-    boxdata = box(boxnumber);
-    if (boxdata == null)
+    if (boxdata == null) {
         normal_error("pdf backend", "xforms cannot be used with a void box");
+    } else if (type(boxdata) != hlist_node && type(boxdata) != vlist_node) {
+        luaL_error(L, "saveboxresource: incompatible node type (%s)\n", get_node_name(type(boxdata), subtype(boxdata)));
+        return 0;
+    }
     static_pdf->xform_count++;
     index = pdf_create_obj(static_pdf, obj_type_xform, static_pdf->xform_count);
     set_obj_data_ptr(static_pdf, index, pdf_get_mem(static_pdf, pdfmem_xform_size));
@@ -3251,7 +3260,6 @@ static int tex_save_box_resource(lua_State * L)
     set_obj_xform_depth(static_pdf, index, depth(boxdata));
     set_obj_xform_type(static_pdf, index, type);
     set_obj_xform_margin(static_pdf, index, margin);
-    box(boxnumber) = null;
     last_saved_box_index = index;
     lua_pushinteger(L, index);
     if (immediate) {
diff --git a/source/texk/web2c/luatexdir/lua/luanode.c b/source/texk/web2c/luatexdir/lua/luanode.c
index 23713c6f3..8b1865edf 100644
--- a/source/texk/web2c/luatexdir/lua/luanode.c
+++ b/source/texk/web2c/luatexdir/lua/luanode.c
@@ -86,7 +86,7 @@ void lua_node_filter(int filterid, int extrainfo, halfword head_node, halfword *
         }
     } else {
         /*tex append to old head */
-        start_done = nodelist_from_lua(Luas);
+        start_done = nodelist_from_lua(Luas, -1);
         try_couple_nodes(head_node,start_done);
     }
     /*tex redundant as we set top anyway */
@@ -143,7 +143,7 @@ int lua_linebreak_callback(int is_broken, halfword head_node, halfword * new_hea
     lua_settop(Luas, s_top);
     p = lua_touserdata(Luas, -1);
     if (p != NULL) {
-        a = nodelist_from_lua(Luas);
+        a = nodelist_from_lua(Luas, -1);
         try_couple_nodes(*new_head,a);
         ret = 1;
     }
@@ -232,7 +232,7 @@ halfword lua_hpack_filter(halfword head_node, scaled size, int pack_type, int ex
             ret = null;
         }
     } else {
-        ret = nodelist_from_lua(Luas);
+        ret = nodelist_from_lua(Luas, -1);
     }
     lua_settop(Luas, s_top);
     if (fix_node_lists)
@@ -293,7 +293,7 @@ halfword lua_vpack_filter(halfword head_node, scaled size, int pack_type, scaled
             ret = null;
         }
     } else {
-        ret = nodelist_from_lua(Luas);
+        ret = nodelist_from_lua(Luas, -1);
     }
     lua_settop(Luas, s_top);
     if (fix_node_lists)
diff --git a/source/texk/web2c/luatexdir/lua/luatex-api.h b/source/texk/web2c/luatexdir/lua/luatex-api.h
index 2a43529e3..0c9575c3b 100644
--- a/source/texk/web2c/luatexdir/lua/luatex-api.h
+++ b/source/texk/web2c/luatexdir/lua/luatex-api.h
@@ -146,7 +146,7 @@ extern int nodelib_getlist(lua_State * L, int n);
 
 extern int luaopen_node(lua_State * L);
 extern void nodelist_to_lua(lua_State * L, int n);
-extern int nodelist_from_lua(lua_State * L);
+extern int nodelist_from_lua(lua_State * L, int n);
 
 extern int dimen_to_number(lua_State * L, const char *s);
 
diff --git a/source/texk/web2c/luatexdir/tex/mlist.c b/source/texk/web2c/luatexdir/tex/mlist.c
index 0d4edaf0f..5ad8c46c1 100644
--- a/source/texk/web2c/luatexdir/tex/mlist.c
+++ b/source/texk/web2c/luatexdir/tex/mlist.c
@@ -1813,7 +1813,7 @@ void run_mlist_to_hlist(halfword p, boolean penalties, int mstyle)
             luatex_error(Luas, (i == LUA_ERRRUN ? 0 : 1));
             return;
         }
-        a = nodelist_from_lua(Luas);
+        a = nodelist_from_lua(Luas, -1);
         /* alink(vlink(a)) = null; */
         vlink(temp_head) = a;
         lua_settop(Luas, sfix);
