diff --git a/source/libs/lua52/lua-5.2.3/src/lstring.c b/source/libs/lua52/lua-5.2.3/src/lstring.c
index af96c89c1832071dee4b299979e83a4fddaca2fe..f438915a50d0227f69ecbcdc0e100eb8effe7978 100644
--- a/source/libs/lua52/lua-5.2.3/src/lstring.c
+++ b/source/libs/lua52/lua-5.2.3/src/lstring.c
@@ -23,7 +23,7 @@
 ** compute its hash
 */
 #if !defined(LUAI_HASHLIMIT)
-#define LUAI_HASHLIMIT		5
+#define LUAI_HASHLIMIT		6
 #endif
 
 
diff --git a/source/libs/luajit/LuaJIT-2.0.2/src/lj_str.c b/source/libs/luajit/LuaJIT-2.0.2/src/lj_str.c
index 6548ee4d382b33b1affa53b91ec6f3420989dcdc..ea49c6a56107f2058fb11df71b8a0e45e9060f12 100644
--- a/source/libs/luajit/LuaJIT-2.0.2/src/lj_str.c
+++ b/source/libs/luajit/LuaJIT-2.0.2/src/lj_str.c
@@ -90,6 +90,8 @@ void lj_str_resize(lua_State *L, MSize newmask)
   g->strhash = newhash;
 }
 
+#define cast(t, exp)	((t)(exp))
+int luajitex_choose_hash_function = 0; 
 /* Intern a string and return string object. */
 GCstr *lj_str_new(lua_State *L, const char *str, size_t lenx)
 {
@@ -98,27 +100,44 @@ GCstr *lj_str_new(lua_State *L, const char *str, size_t lenx)
   GCobj *o;
   MSize len = (MSize)lenx;
   MSize a, b, h = len;
+  size_t step ;
+  size_t l1 ;
   if (lenx >= LJ_MAX_STR)
     lj_err_msg(L, LJ_ERR_STROV);
   g = G(L);
+
+  if (len==0)
+    return &g->strempty; 
+  if (luajitex_choose_hash_function==0) { 
+    /* Lua 5.1.5 hash function */
+    /* for 5.2 max methods we also need to patch the vm eq */ 
+    step = (len>>6)+1;  /* if string is too long, don't hash all its chars  Was 5, we try 6*/
+    for (l1=len; l1>=step; l1-=step)  /* compute hash */
+      h = h ^ ((h<<5)+(h>>2)+cast(unsigned char, str[l1-1])); 
+   } else { 
+  /* LuaJIT 2.0.2 hash function */
   /* Compute string hash. Constants taken from lookup3 hash by Bob Jenkins. */
-  if (len >= 4) {  /* Caveat: unaligned access! */
-    a = lj_getu32(str);
-    h ^= lj_getu32(str+len-4);
-    b = lj_getu32(str+(len>>1)-2);
-    h ^= b; h -= lj_rol(b, 14);
-    b += lj_getu32(str+(len>>2)-1);
-  } else if (len > 0) {
-    a = *(const uint8_t *)str;
-    h ^= *(const uint8_t *)(str+len-1);
-    b = *(const uint8_t *)(str+(len>>1));
-    h ^= b; h -= lj_rol(b, 14);
-  } else {
-    return &g->strempty;
-  }
-  a ^= h; a -= lj_rol(h, 11);
-  b ^= a; b -= lj_rol(a, 25);
-  h ^= b; h -= lj_rol(b, 16);
+    if (len >= 4) {  /* Caveat: unaligned access! */
+      a = lj_getu32(str);
+      h ^= lj_getu32(str+len-4);
+      b = lj_getu32(str+(len>>1)-2);
+      h ^= b; h -= lj_rol(b, 14);
+      b += lj_getu32(str+(len>>2)-1);
+    } else if (len > 0) {
+      a = *(const uint8_t *)str;
+      h ^= *(const uint8_t *)(str+len-1);
+      b = *(const uint8_t *)(str+(len>>1));
+      h ^= b; h -= lj_rol(b, 14);
+    } else {
+       /* Already done, kept for reference */ 
+       return &g->strempty;
+    }
+    a ^= h; a -= lj_rol(h, 11);
+    b ^= a; b -= lj_rol(a, 25);
+    h ^= b; h -= lj_rol(b, 16);
+  } 
+
+
   /* Check if the string has already been interned. */
   o = gcref(g->strhash[h & g->strmask]);
   if (LJ_LIKELY((((uintptr_t)str+len-1) & (LJ_PAGESIZE-1)) <= LJ_PAGESIZE-4)) {
diff --git a/source/texk/web2c/lib/texmfmp.c b/source/texk/web2c/lib/texmfmp.c
index e45e8446d015875bdfc0d49c80f604e6c4d0f5fb..cc67affe9a864cf0f6d43e799846c3d00d84c1bd 100644
--- a/source/texk/web2c/lib/texmfmp.c
+++ b/source/texk/web2c/lib/texmfmp.c
@@ -2749,10 +2749,10 @@ makesrcspecial (strnumber srcfilename, int lineno)
 
 #define check_nprintf(size_get, size_want) \
     if ((unsigned)(size_get) >= (unsigned)(size_want)) \
-        pdftex_fail ("snprintf failed: file %s, line %d", __FILE__, __LINE__);
+        luatex_fail ("snprintf failed: file %s, line %d", __FILE__, __LINE__);
 #  define check_buf(size, buf_size)                         \
     if ((unsigned)(size) > (unsigned)(buf_size))            \
-        pdftex_fail("buffer overflow at file %s, line %d", __FILE__,  __LINE__ )
+        luatex_fail("buffer overflow at file %s, line %d", __FILE__,  __LINE__ )
 #  define xfree(p)            do { if (p != NULL) free(p); p = NULL; } while (0)
 #  define MAX_CSTRING_LEN     1024 * 1024
 
@@ -2760,14 +2760,14 @@ makesrcspecial (strnumber srcfilename, int lineno)
 #  define PRINTF_BUF_SIZE     1024
 static char print_buf[PRINTF_BUF_SIZE];
 
-/* Helper for pdftex_fail. */
+/* Helper for luatex_fail. */
 static void safe_print(const char *str)
 {
     const char *c;
     for (c = str; *c; ++c)
         print(*c);
 }
-/* pdftex_fail may be called when a buffer overflow has happened/is
+/* luatex_fail may be called when a buffer overflow has happened/is
    happening, therefore may not call mktexstring.  However, with the
    current implementation it appears that error messages are misleading,
    possibly because pool overflows are detected too late.
@@ -2775,7 +2775,7 @@ static void safe_print(const char *str)
    The output format of this fuction must be the same as pdf_error in
    pdftex.web! */
 __attribute__ ((noreturn, format(printf, 1, 2)))
-void pdftex_fail(const char *fmt, ...)
+void luatex_fail(const char *fmt, ...)
 {
     va_list args;
     va_start(args, fmt);
diff --git a/source/texk/web2c/luatexdir/font/luafont.w b/source/texk/web2c/luatexdir/font/luafont.w
index 152e511880197f6baa78939f26634bf4928809a3..1861898f0da5003881ea58f3db7e56bb7e99cde7 100644
--- a/source/texk/web2c/luatexdir/font/luafont.w
+++ b/source/texk/web2c/luatexdir/font/luafont.w
@@ -584,40 +584,56 @@ static void append_float(eight_bits ** cpp, float a)
     *cpp = cp;
 }
 
-#define lua_roundnumber(a,b) (int)floor((double)lua_tonumber(L,-1)+0.5)
-
-static int numeric_field(lua_State * L, const char *name, int dflt)
-{
-    int i = dflt;
-    lua_pushstring(L, name);
-    lua_rawget(L, -2);
-    if (lua_isnumber(L, -1)) {
-        i = lua_roundnumber(L, -1);
-    }
-    lua_pop(L, 1);
-    return i;
-}
-
-static int n_numeric_field(lua_State * L, int name_index, int dflt)
-{
-    register int i = dflt;
-    lua_rawgeti(L, LUA_REGISTRYINDEX, name_index);      /* fetch the stringptr */
-    lua_rawget(L, -2);
-    if (lua_type(L, -1) == LUA_TNUMBER) {
-        i = lua_roundnumber(L, -1);
-    }
-    lua_pop(L, 1);
-    return i;
-}
-
-
-static int enum_field(lua_State * L, const char *name, int dflt,
+//#define lua_roundnumber(a,b) (int)floor((double)lua_tonumber(L,-1)+0.5)
+
+
+/* static int n_numeric_field(lua_State * L, int name_index, int dflt) */
+/* { */
+/*     register int i = dflt; */
+/*     lua_rawgeti(L, LUA_REGISTRYINDEX, name_index);      /\* fetch the stringptr *\/ */
+/*     lua_rawget(L, -2); */
+/*     if (lua_type(L, -1) == LUA_TNUMBER) { */
+/*         i = lua_roundnumber(L, -1); */
+/*     } */
+/*     lua_pop(L, 1); */
+/*     return i; */
+/* } */
+
+
+
+
+/* static int enum_field(lua_State * L, const char *name, int dflt, */
+/*                       const char **values) */
+/* { */
+/*     int k; */
+/*     const char *s; */
+/*     int i = dflt; */
+/*     lua_pushstring(L, name); */
+/*     lua_rawget(L, -2); */
+/*     if (lua_isnumber(L, -1)) { */
+/*         i=(int)lua_tonumber(L, -1); */
+/*     } else if (lua_isstring(L, -1)) { */
+/*         s = lua_tostring(L, -1); */
+/*         k = 0; */
+/*         while (values[k] != NULL) { */
+/*             if (strcmp(values[k], s) == 0) { */
+/*                 i = k; */
+/*                 break; */
+/*             } */
+/*             k++; */
+/*         } */
+/*     } */
+/*     lua_pop(L, 1); */
+/*     return i; */
+/* } */
+
+static int n_enum_field(lua_State * L, int name_index, int dflt,
                       const char **values)
 {
     int k;
     const char *s;
     int i = dflt;
-    lua_pushstring(L, name);
+    lua_rawgeti(L, LUA_REGISTRYINDEX, name_index);      /* fetch the stringptr */
     lua_rawget(L, -2);
     if (lua_isnumber(L, -1)) {
         i=(int)lua_tonumber(L, -1);
@@ -636,17 +652,19 @@ static int enum_field(lua_State * L, const char *name, int dflt,
     return i;
 }
 
-static int boolean_field(lua_State * L, const char *name, int dflt)
-{
-    int i = dflt;
-    lua_pushstring(L, name);
-    lua_rawget(L, -2);
-    if (lua_isboolean(L, -1)) {
-        i = lua_toboolean(L, -1);
-    }
-    lua_pop(L, 1);
-    return i;
-}
+
+
+/* static int boolean_field(lua_State * L, const char *name, int dflt) */
+/* { */
+/*     int i = dflt; */
+/*     lua_pushstring(L, name); */
+/*     lua_rawget(L, -2); */
+/*     if (lua_isboolean(L, -1)) { */
+/*         i = lua_toboolean(L, -1); */
+/*     } */
+/*     lua_pop(L, 1); */
+/*     return i; */
+/* } */
 
 static int n_boolean_field(lua_State * L, int name_index, int dflt)
 {
@@ -661,23 +679,7 @@ static int n_boolean_field(lua_State * L, int name_index, int dflt)
 }
 
 
-static char *string_field(lua_State * L, const char *name, const char *dflt)
-{
-    char *i;
-    lua_pushstring(L, name);
-    lua_rawget(L, -2);
-    if (lua_isstring(L, -1)) {
-        i = xstrdup(lua_tostring(L, -1));
-    } else if (dflt == NULL) {
-        i = NULL;
-    } else {
-        i = xstrdup(dflt);
-    }
-    lua_pop(L, 1);
-    return i;
-}
-
-static char *n_string_field(lua_State * L, int name_index, char *dflt)
+static char *n_string_field_copy(lua_State * L, int name_index, const char *dflt)
 {
     char *i;
     lua_rawgeti(L, LUA_REGISTRYINDEX, name_index);      /* fetch the stringptr */
@@ -693,138 +695,13 @@ static char *n_string_field(lua_State * L, int name_index, char *dflt)
     return i;
 }
 
-#define init_luaS_index(a) do {					\
-	lua_pushliteral(L,#a);					\
-	luaS_##a##_ptr = lua_tostring(L,-1);			\
-	luaS_##a##_index = luaL_ref (L,LUA_REGISTRYINDEX);	\
-  } while (0)
-
-#define make_luaS_index(a)      \
-  static int luaS_##a##_index = 0;    \
-  static const char * luaS_##a##_ptr = NULL
-
-#define luaS_index(a) luaS_##a##_index
-
-#define luaS_ptr_eq(a,b) (a==luaS_##b##_ptr)
-
-make_luaS_index(width);
-make_luaS_index(height);
-make_luaS_index(depth);
-make_luaS_index(italic);
-make_luaS_index(top_accent);
-make_luaS_index(bot_accent);
-make_luaS_index(index);
-make_luaS_index(left_protruding);
-make_luaS_index(right_protruding);
-make_luaS_index(expansion_factor);
-make_luaS_index(top);
-make_luaS_index(bot);
-make_luaS_index(rep);
-make_luaS_index(mid);
-make_luaS_index(next);
-make_luaS_index(used);
-make_luaS_index(name);
-make_luaS_index(tounicode);
-make_luaS_index(font);
-make_luaS_index(char);
-make_luaS_index(slot);
-make_luaS_index(comment);
-make_luaS_index(nop);
-make_luaS_index(push);
-make_luaS_index(pop);
-make_luaS_index(rule);
-make_luaS_index(right);
-make_luaS_index(node);
-make_luaS_index(down);
-make_luaS_index(special);
-make_luaS_index(image);
-make_luaS_index(slant);
-make_luaS_index(space);
-make_luaS_index(space_stretch);
-make_luaS_index(space_shrink);
-make_luaS_index(x_height);
-make_luaS_index(quad);
-make_luaS_index(extra_space);
-make_luaS_index(left_boundary);
-make_luaS_index(right_boundary);
-make_luaS_index(kerns);
-make_luaS_index(ligatures);
-make_luaS_index(fonts);
-make_luaS_index(extender);
-make_luaS_index(start);
-make_luaS_index(end);
-make_luaS_index(advance);
-make_luaS_index(glyph);
-make_luaS_index(extensible);
-make_luaS_index(horiz_variants);
-make_luaS_index(vert_variants);
-make_luaS_index(mathkern);
-make_luaS_index(commands);
-make_luaS_index(scale);
-make_luaS_index(lua);
-
-static void init_font_string_pointers(lua_State * L)
+static const char *n_string_field(lua_State * L, int name_index)
 {
-    init_luaS_index(width);
-    init_luaS_index(height);
-    init_luaS_index(depth);
-    init_luaS_index(italic);
-    init_luaS_index(top_accent);
-    init_luaS_index(bot_accent);
-    init_luaS_index(index);
-    init_luaS_index(left_protruding);
-    init_luaS_index(right_protruding);
-    init_luaS_index(expansion_factor);
-    init_luaS_index(top);
-    init_luaS_index(bot);
-    init_luaS_index(rep);
-    init_luaS_index(mid);
-    init_luaS_index(next);
-    init_luaS_index(used);
-    init_luaS_index(name);
-    init_luaS_index(tounicode);
-    init_luaS_index(font);
-    init_luaS_index(char);
-    init_luaS_index(slot);
-    init_luaS_index(comment);
-    init_luaS_index(nop);
-    init_luaS_index(push);
-    init_luaS_index(pop);
-    init_luaS_index(rule);
-    init_luaS_index(right);
-    init_luaS_index(node);
-    init_luaS_index(down);
-    init_luaS_index(special);
-    init_luaS_index(image);
-
-    init_luaS_index(slant);
-    init_luaS_index(space);
-    init_luaS_index(space_stretch);
-    init_luaS_index(space_shrink);
-    init_luaS_index(x_height);
-    init_luaS_index(quad);
-    init_luaS_index(extra_space);
-
-    init_luaS_index(left_boundary);
-    init_luaS_index(right_boundary);
-    init_luaS_index(kerns);
-    init_luaS_index(ligatures);
-    init_luaS_index(fonts);
-
-    init_luaS_index(extender);
-    init_luaS_index(start);
-    init_luaS_index(end);
-    init_luaS_index(advance);
-    init_luaS_index(glyph);
-
-    init_luaS_index(extensible);
-    init_luaS_index(horiz_variants);
-    init_luaS_index(vert_variants);
-    init_luaS_index(mathkern);
-    init_luaS_index(commands);
-    init_luaS_index(scale);
-    init_luaS_index(lua);
+    lua_rawgeti(L, LUA_REGISTRYINDEX, name_index);      /* fetch the stringptr */ 
+    lua_rawget(L, -2);
+    return lua_tostring(L,-1);
 }
+/*static void init_font_string_pointers(lua_State * L){}*/
 
 static int count_char_packet_bytes(lua_State * L)
 {
@@ -837,30 +714,30 @@ static int count_char_packet_bytes(lua_State * L)
             lua_rawgeti(L, -1, 1);
             if (lua_isstring(L, -1)) {
                 const char *s = lua_tostring(L, -1);
-                if (luaS_ptr_eq(s, font)) {
+                if (lua_key_eq(s, font)) {
                     l += 5;
                     ff = 1;
-                } else if (luaS_ptr_eq(s, char)) {
+                } else if (lua_key_eq(s, char)) {
                     if (ff == 0) {
                         l += 5;
                     }
                     l += 5;
                     ff = 1;
-                } else if (luaS_ptr_eq(s, slot)) {
+                } else if (lua_key_eq(s, slot)) {
                     l += 10;
                     ff = 1;
-                } else if (luaS_ptr_eq(s, comment) || luaS_ptr_eq(s, nop)) {
+                } else if (lua_key_eq(s, comment) || lua_key_eq(s, nop)) {
                     ;
-                } else if (luaS_ptr_eq(s, push) || luaS_ptr_eq(s, pop)) {
+                } else if (lua_key_eq(s, push) || lua_key_eq(s, pop)) {
                     l++;
-                } else if (luaS_ptr_eq(s, rule)) {
+                } else if (lua_key_eq(s, rule)) {
                     l += 9;
-                } else if (luaS_ptr_eq(s, right) || luaS_ptr_eq(s, node)
-                           || luaS_ptr_eq(s, down) || luaS_ptr_eq(s, image)) {
+                } else if (lua_key_eq(s, right) || lua_key_eq(s, node)
+                           || lua_key_eq(s, down) || lua_key_eq(s, image)) {
                     l += 5;
-                } else if (luaS_ptr_eq(s, scale)) {
+                } else if (lua_key_eq(s, scale)) {
                     l += sizeof(float) + 1;
-                } else if (luaS_ptr_eq(s, special) || luaS_ptr_eq(s, lua)) {
+                } else if (lua_key_eq(s, special) || lua_key_eq(s, lua)) {
                     size_t len;
                     lua_rawgeti(L, -2, 2);
                     if (lua_isstring(L, -1)) {
@@ -922,16 +799,16 @@ read_char_packets(lua_State * L, int *l_fonts, charinfo * co, int atsize)
             if (lua_isstring(L, -1)) {
                 s = lua_tostring(L, -1);
                 cmd = 0;
-                if (luaS_ptr_eq(s, font)) {
+                if (lua_key_eq(s, font)) {
                     cmd = packet_font_code;
-                } else if (luaS_ptr_eq(s, char)) {
+                } else if (lua_key_eq(s, char)) {
                     cmd = packet_char_code;
                     if (ff == 0) {
                         append_packet(packet_font_code);
                         ff = l_fonts[1];
                         do_store_four(ff);
                     }
-                } else if (luaS_ptr_eq(s, slot)) {
+                } else if (lua_key_eq(s, slot)) {
                     cmd = packet_nop_code;
                     lua_rawgeti(L, -2, 2);
                     n = (int) luaL_checkinteger(L, -1);
@@ -943,27 +820,27 @@ read_char_packets(lua_State * L, int *l_fonts, charinfo * co, int atsize)
                     do_store_four(ff);
                     append_packet(packet_char_code);
                     do_store_four(n);
-                } else if (luaS_ptr_eq(s, comment) || luaS_ptr_eq(s, nop)) {
+                } else if (lua_key_eq(s, comment) || lua_key_eq(s, nop)) {
                     cmd = packet_nop_code;
-                } else if (luaS_ptr_eq(s, node)) {
+                } else if (lua_key_eq(s, node)) {
                     cmd = packet_node_code;
-                } else if (luaS_ptr_eq(s, push)) {
+                } else if (lua_key_eq(s, push)) {
                     cmd = packet_push_code;
-                } else if (luaS_ptr_eq(s, pop)) {
+                } else if (lua_key_eq(s, pop)) {
                     cmd = packet_pop_code;
-                } else if (luaS_ptr_eq(s, rule)) {
+                } else if (lua_key_eq(s, rule)) {
                     cmd = packet_rule_code;
-                } else if (luaS_ptr_eq(s, right)) {
+                } else if (lua_key_eq(s, right)) {
                     cmd = packet_right_code;
-                } else if (luaS_ptr_eq(s, down)) {
+                } else if (lua_key_eq(s, down)) {
                     cmd = packet_down_code;
-                } else if (luaS_ptr_eq(s, special)) {
+                } else if (lua_key_eq(s, special)) {
                     cmd = packet_special_code;
-                } else if (luaS_ptr_eq(s, image)) {
+                } else if (lua_key_eq(s, image)) {
                     cmd = packet_image_code;
-                } else if (luaS_ptr_eq(s, scale)) {
+                } else if (lua_key_eq(s, scale)) {
                     cmd = packet_scale_code;
-                } else if (luaS_ptr_eq(s, lua)) {
+                } else if (lua_key_eq(s, lua)) {
                     cmd = packet_lua_code;
                 }
 
@@ -1071,15 +948,16 @@ static void read_lua_cidinfo(lua_State * L, int f)
 {
     int i;
     char *s;
-    lua_getfield(L, -1, "cidinfo");
+    //lua_getfield(L, -1, "cidinfo");
+    lua_key_rawgeti(cidinfo);
     if (lua_istable(L, -1)) {
-        i = numeric_field(L, "version", 0);
+        i = lua_numeric_field_by_index(L,lua_key_index(version), 0);
         set_font_cidversion(f, i);
-        i = numeric_field(L, "supplement", 0);
+        i = lua_numeric_field_by_index(L,lua_key_index(supplement), 0);
         set_font_cidsupplement(f, i);
-        s = string_field(L, "registry", "Adobe");       /* Adobe-Identity-0 */
+        s = n_string_field_copy(L, lua_key_index(registry), "Adobe");       /* Adobe-Identity-0 */
         set_font_cidregistry(f, s);
-        s = string_field(L, "ordering", "Identity");
+        s = n_string_field_copy(L, lua_key_index(ordering), "Identity");
         set_font_cidordering(f, s);
     }
     lua_pop(L, 1);
@@ -1091,7 +969,8 @@ static void read_lua_parameters(lua_State * L, int f)
 {
     int i, n;
     const char *s;
-    lua_getfield(L, -1, "parameters");
+    //lua_getfield(L, -1, "parameters");
+    lua_key_rawgeti(parameters);
     if (lua_istable(L, -1)) {
         /* the number of parameters is the max(IntegerKeys(L)),7) */
         n = 7;
@@ -1126,19 +1005,19 @@ static void read_lua_parameters(lua_State * L, int f)
             } else if (lua_isstring(L, -2)) {
                 s = lua_tostring(L, -2);
                 n = (lua_isnumber(L, -1) ? lua_roundnumber(L, -1) : 0);
-                if (luaS_ptr_eq(s, slant)) {
+                if (lua_key_eq(s, slant)) {
                     set_font_param(f, slant_code, n);
-                } else if (luaS_ptr_eq(s, space)) {
+                } else if (lua_key_eq(s, space)) {
                     set_font_param(f, space_code, n);
-                } else if (luaS_ptr_eq(s, space_stretch)) {
+                } else if (lua_key_eq(s, space_stretch)) {
                     set_font_param(f, space_stretch_code, n);
-                } else if (luaS_ptr_eq(s, space_shrink)) {
+                } else if (lua_key_eq(s, space_shrink)) {
                     set_font_param(f, space_shrink_code, n);
-                } else if (luaS_ptr_eq(s, x_height)) {
+                } else if (lua_key_eq(s, x_height)) {
                     set_font_param(f, x_height_code, n);
-                } else if (luaS_ptr_eq(s, quad)) {
+                } else if (lua_key_eq(s, quad)) {
                     set_font_param(f, quad_code, n);
-                } else if (luaS_ptr_eq(s, extra_space)) {
+                } else if (lua_key_eq(s, extra_space)) {
                     set_font_param(f, extra_space_code, n);
                 }
             }
@@ -1153,7 +1032,8 @@ static void read_lua_parameters(lua_State * L, int f)
 static void read_lua_math_parameters(lua_State * L, int f)
 {
     int i = 0, n = 0;
-    lua_getfield(L, -1, "MathConstants");
+    //lua_getfield(L, -1, "MathConstants");
+    lua_key_rawgeti(MathConstants);
     if (lua_istable(L, -1)) {
         lua_pushnil(L);
         while (lua_next(L, -2) != 0) {
@@ -1176,36 +1056,24 @@ static void read_lua_math_parameters(lua_State * L, int f)
 #define MIN_INF -0x7FFFFFFF
 
 
-static void store_math_kerns(lua_State * L, charinfo * co, int id)
+static void store_math_kerns(lua_State * L, int index, charinfo * co, int id)
 {
-    int l, k, i;
+    int l, k; 
     scaled ht, krn;
+    lua_rawgeti(L, LUA_REGISTRYINDEX, index);lua_rawget(L, -2);
     if (lua_istable(L, -1) && ((k = (int) lua_rawlen(L, -1)) > 0)) {
         for (l = 0; l < k; l++) {
             lua_rawgeti(L, -1, (l + 1));
             if (lua_istable(L, -1)) {
-                lua_getfield(L, -1, "height");
-                if (lua_isnumber(L, -1)) {
-                    i=(int)lua_tonumber(L, -1);
-                    ht = (scaled) i;
-                } else {
-                    ht = MIN_INF;
-                }
-                lua_pop(L, 1);
-                lua_getfield(L, -1, "kern");
-                if (lua_isnumber(L, -1)) {
-                    i=(int)lua_tonumber(L, -1);
-                    krn = (scaled) i;
-                } else {
-                    krn = MIN_INF;
-                }
-                lua_pop(L, 1);
+	        ht = (scaled) lua_numeric_field_by_index(L, lua_key_index(height), MIN_INF);
+		krn = (scaled) lua_numeric_field_by_index(L, lua_key_index(kern), MIN_INF);
                 if (krn > MIN_INF && ht > MIN_INF)
                     add_charinfo_math_kern(co, id, ht, krn);
             }
             lua_pop(L, 1);
         }
     }
+    lua_pop(L, 1);
 }
 
 @ @c
@@ -1226,66 +1094,69 @@ font_char_from_lua(lua_State * L, internal_font_number f, int i,
     if (lua_istable(L, -1)) {
         co = get_charinfo(f, i);
         set_charinfo_tag(co, 0);
-        j = n_numeric_field(L, luaS_width_index, 0);
+        j = lua_numeric_field_by_index(L, lua_key_index(width), 0);
         set_charinfo_width(co, j);
-        j = n_numeric_field(L, luaS_height_index, 0);
+        j = lua_numeric_field_by_index(L, lua_key_index(height), 0);
         set_charinfo_height(co, j);
-        j = n_numeric_field(L, luaS_depth_index, 0);
+        j = lua_numeric_field_by_index(L, lua_key_index(depth), 0);
         set_charinfo_depth(co, j);
-        j = n_numeric_field(L, luaS_italic_index, 0);
+        j = lua_numeric_field_by_index(L, lua_key_index(italic), 0);
         set_charinfo_italic(co, j);
-        j = n_numeric_field(L, luaS_index_index, 0);
+        j = lua_numeric_field_by_index(L, lua_key_index(index), 0);
         set_charinfo_index(co, j);
-        j = n_numeric_field(L, luaS_expansion_factor_index, 0);
+        j = lua_numeric_field_by_index(L, lua_key_index(expansion_factor), 0);
         set_charinfo_ef(co, j);
-        j = n_numeric_field(L, luaS_left_protruding_index, 0);
+        j = lua_numeric_field_by_index(L, lua_key_index(left_protruding), 0);
         set_charinfo_lp(co, j);
-        j = n_numeric_field(L, luaS_right_protruding_index, 0);
+        j = lua_numeric_field_by_index(L, lua_key_index(right_protruding), 0);
         set_charinfo_rp(co, j);
-        k = n_boolean_field(L, luaS_used_index, 0);
+        k = n_boolean_field(L, lua_key_index(used), 0);
         set_charinfo_used(co, k);
-        s = n_string_field(L, luaS_name_index, NULL);
+        s = n_string_field(L, lua_key_index(name));
         if (s != NULL)
             set_charinfo_name(co, xstrdup(s));
         else
             set_charinfo_name(co, NULL);
-        s = n_string_field(L, luaS_tounicode_index, NULL);
+        /* n_string_field leaves a value on stack*/
+        lua_pop(L,1); 
+        s = n_string_field(L, lua_key_index(tounicode));
         if (s != NULL)
             set_charinfo_tounicode(co, xstrdup(s));
         else
             set_charinfo_tounicode(co, NULL);
-
+	/* n_string_field leaves a value on stack*/
+        lua_pop(L,1); 
         if (has_math) {
-            j = n_numeric_field(L, luaS_top_accent_index, INT_MIN);
+            j = lua_numeric_field_by_index(L, lua_key_index(top_accent), INT_MIN);
             set_charinfo_top_accent(co, j);
-            j = n_numeric_field(L, luaS_bot_accent_index, INT_MIN);
+            j = lua_numeric_field_by_index(L, lua_key_index(bot_accent), INT_MIN);
             set_charinfo_bot_accent(co, j);
-            k = n_numeric_field(L, luaS_next_index, -1);
+            k = lua_numeric_field_by_index(L, lua_key_index(next), -1);
             if (k >= 0) {
                 set_charinfo_tag(co, list_tag);
                 set_charinfo_remainder(co, k);
             }
 
-            lua_rawgeti(L, LUA_REGISTRYINDEX, luaS_extensible_index);
+            lua_rawgeti(L, LUA_REGISTRYINDEX, lua_key_index(extensible));
             lua_rawget(L, -2);
             if (lua_istable(L, -1)) {
                 int top, bot, mid, rep;
-                top = n_numeric_field(L, luaS_top_index, 0);
-                bot = n_numeric_field(L, luaS_bot_index, 0);
-                mid = n_numeric_field(L, luaS_mid_index, 0);
-                rep = n_numeric_field(L, luaS_rep_index, 0);
+                top = lua_numeric_field_by_index(L, lua_key_index(top), 0);
+                bot = lua_numeric_field_by_index(L, lua_key_index(bot), 0);
+                mid = lua_numeric_field_by_index(L, lua_key_index(mid), 0);
+                rep = lua_numeric_field_by_index(L, lua_key_index(rep), 0);
                 if (top != 0 || bot != 0 || mid != 0 || rep != 0) {
                     set_charinfo_tag(co, ext_tag);
                     set_charinfo_extensible(co, top, bot, mid, rep);
                 } else {
-                    pdftex_warn
+                    luatex_warn
                         ("lua-loaded font %s char [U+%X] has an invalid extensible field!",
                          font_name(f), (int) i);
                 }
             }
             lua_pop(L, 1);
 
-            lua_rawgeti(L, LUA_REGISTRYINDEX, luaS_horiz_variants_index);
+            lua_rawgeti(L, LUA_REGISTRYINDEX, lua_key_index(horiz_variants));
             lua_rawget(L, -2);
             if (lua_istable(L, -1)) {
                 int glyph, startconnect, endconnect, advance, extender;
@@ -1295,11 +1166,11 @@ font_char_from_lua(lua_State * L, internal_font_number f, int i,
                 for (k = 1;; k++) {
                     lua_rawgeti(L, -1, k);
                     if (lua_istable(L, -1)) {
-                        glyph = n_numeric_field(L, luaS_glyph_index, 0);
-                        extender = n_numeric_field(L, luaS_extender_index, 0);
-                        startconnect = n_numeric_field(L, luaS_start_index, 0);
-                        endconnect = n_numeric_field(L, luaS_end_index, 0);
-                        advance = n_numeric_field(L, luaS_advance_index, 0);
+                        glyph = lua_numeric_field_by_index(L, lua_key_index(glyph), 0);
+                        extender = lua_numeric_field_by_index(L, lua_key_index(extender), 0);
+                        startconnect = lua_numeric_field_by_index(L, lua_key_index(start), 0);
+                        endconnect = lua_numeric_field_by_index(L, lua_key_index(end), 0);
+                        advance = lua_numeric_field_by_index(L, lua_key_index(advance), 0);
                         h = new_variant(glyph, startconnect, endconnect,
                                         advance, extender);
                         add_charinfo_hor_variant(co, h);
@@ -1312,7 +1183,7 @@ font_char_from_lua(lua_State * L, internal_font_number f, int i,
             }
             lua_pop(L, 1);
 
-            lua_rawgeti(L, LUA_REGISTRYINDEX, luaS_vert_variants_index);
+            lua_rawgeti(L, LUA_REGISTRYINDEX, lua_key_index(vert_variants));
             lua_rawget(L, -2);
             if (lua_istable(L, -1)) {
                 int glyph, startconnect, endconnect, advance, extender;
@@ -1322,11 +1193,11 @@ font_char_from_lua(lua_State * L, internal_font_number f, int i,
                 for (k = 1;; k++) {
                     lua_rawgeti(L, -1, k);
                     if (lua_istable(L, -1)) {
-                        glyph = n_numeric_field(L, luaS_glyph_index, 0);
-                        extender = n_numeric_field(L, luaS_extender_index, 0);
-                        startconnect = n_numeric_field(L, luaS_start_index, 0);
-                        endconnect = n_numeric_field(L, luaS_end_index, 0);
-                        advance = n_numeric_field(L, luaS_advance_index, 0);
+                        glyph = lua_numeric_field_by_index(L, lua_key_index(glyph), 0);
+                        extender = lua_numeric_field_by_index(L, lua_key_index(extender), 0);
+                        startconnect = lua_numeric_field_by_index(L, lua_key_index(start), 0);
+                        endconnect = lua_numeric_field_by_index(L, lua_key_index(end), 0);
+                        advance = lua_numeric_field_by_index(L, lua_key_index(advance), 0);
                         h = new_variant(glyph, startconnect, endconnect,
                                         advance, extender);
                         add_charinfo_vert_variant(co, h);
@@ -1348,29 +1219,21 @@ font_char_from_lua(lua_State * L, internal_font_number f, int i,
    |["top_right"]   ={ { ["height"]=676, ["kern"]=115 }, { ["height"]=776,  ["kern"]=45  } },|
    |}|
  */
-            lua_rawgeti(L, LUA_REGISTRYINDEX, luaS_mathkern_index);
+            lua_rawgeti(L, LUA_REGISTRYINDEX, lua_key_index(mathkern));
             lua_rawget(L, -2);
             if (lua_istable(L, -1)) {
-                lua_getfield(L, -1, "top_left");
-                store_math_kerns(L, co, top_left_kern);
-                lua_pop(L, 1);
-                lua_getfield(L, -1, "top_right");
-                store_math_kerns(L, co, top_right_kern);
-                lua_pop(L, 1);
-                lua_getfield(L, -1, "bottom_right");
-                store_math_kerns(L, co, bottom_right_kern);
-                lua_pop(L, 1);
-                lua_getfield(L, -1, "bottom_left");
-                store_math_kerns(L, co, bottom_left_kern);
-                lua_pop(L, 1);
+	        store_math_kerns(L,lua_key_index(top_left), co, top_left_kern);
+                store_math_kerns(L,lua_key_index(top_right), co, top_right_kern);
+                store_math_kerns(L,lua_key_index(bottom_right), co, bottom_right_kern);
+                store_math_kerns(L,lua_key_index(bottom_left), co, bottom_left_kern);
             }
             lua_pop(L, 1);
         }
         /* end of |has_math| */
-        nk = count_hash_items(L, luaS_index(kerns));
+        nk = count_hash_items(L, lua_key_index(kerns));
         if (nk > 0) {
             ckerns = xcalloc((unsigned) (nk + 1), sizeof(kerninfo));
-            lua_rawgeti(L, LUA_REGISTRYINDEX, luaS_index(kerns));
+            lua_rawgeti(L, LUA_REGISTRYINDEX, lua_key_index(kerns));
             lua_rawget(L, -2);
             if (lua_istable(L, -1)) {   /* there are kerns */
                 ctr = 0;
@@ -1383,7 +1246,7 @@ font_char_from_lua(lua_State * L, internal_font_number f, int i,
                             k = non_boundarychar;
                     } else if (lua_isstring(L, -2)) {
                         s = lua_tostring(L, -2);
-                        if (luaS_ptr_eq(s, right_boundary)) {
+                        if (lua_key_eq(s, right_boundary)) {
                             k = right_boundarychar;
                             if (!has_right_boundary(f))
                                 set_right_boundary(f,
@@ -1396,7 +1259,7 @@ font_char_from_lua(lua_State * L, internal_font_number f, int i,
                         set_kern_item(ckerns[ctr], k, j);
                         ctr++;
                     } else {
-                        pdftex_warn
+                        luatex_warn
                             ("lua-loaded font %s char [U+%X] has an invalid kern field!",
                              font_name(f), (int) i);
                     }
@@ -1407,7 +1270,7 @@ font_char_from_lua(lua_State * L, internal_font_number f, int i,
                     set_kern_item(ckerns[ctr], end_kern, 0);
                     set_charinfo_kerns(co, ckerns);
                 } else {
-                    pdftex_warn
+                    luatex_warn
                         ("lua-loaded font %s char [U+%X] has an invalid kerns field!",
                          font_name(f), (int) i);
                 }
@@ -1416,7 +1279,7 @@ font_char_from_lua(lua_State * L, internal_font_number f, int i,
         }
 
         /* packet commands */
-        lua_rawgeti(L, LUA_REGISTRYINDEX, luaS_commands_index);
+        lua_rawgeti(L, LUA_REGISTRYINDEX, lua_key_index(commands));
         lua_rawget(L, -2);
         if (lua_istable(L, -1)) {
             lua_pushnil(L);     /* first key */
@@ -1428,11 +1291,11 @@ font_char_from_lua(lua_State * L, internal_font_number f, int i,
         lua_pop(L, 1);
 
         /* ligatures */
-        nl = count_hash_items(L, luaS_index(ligatures));
+        nl = count_hash_items(L, lua_key_index(ligatures));
 
         if (nl > 0) {
             cligs = xcalloc((unsigned) (nl + 1), sizeof(liginfo));
-            lua_rawgeti(L, LUA_REGISTRYINDEX, luaS_index(ligatures));
+            lua_rawgeti(L, LUA_REGISTRYINDEX, lua_key_index(ligatures));
             lua_rawget(L, -2);
             if (lua_istable(L, -1)) {   /* do ligs */
                 ctr = 0;
@@ -1446,7 +1309,7 @@ font_char_from_lua(lua_State * L, internal_font_number f, int i,
                         }
                     } else if (lua_isstring(L, -2)) {
                         s = lua_tostring(L, -2);
-                        if (luaS_ptr_eq(s, right_boundary)) {
+                        if (lua_key_eq(s, right_boundary)) {
                             k = right_boundarychar;
                             if (!has_right_boundary(f))
                                 set_right_boundary(f,
@@ -1456,15 +1319,15 @@ font_char_from_lua(lua_State * L, internal_font_number f, int i,
                     }
                     r = -1;
                     if (lua_istable(L, -1)) {
-                        r = n_numeric_field(L, luaS_char_index, -1);    /* ligature */
+                        r = lua_numeric_field_by_index(L, lua_key_index(char), -1);    /* ligature */
                     }
                     if (r != -1 && k != non_boundarychar) {
-                        t = enum_field(L, "type", 0, ligature_type_strings);
-                        set_ligature_item(cligs[ctr], (char) ((t * 2) + 1), k,
+		        t = n_enum_field(L, lua_key_index(type), 0, ligature_type_strings);
+		        set_ligature_item(cligs[ctr], (char) ((t * 2) + 1), k,
                                           r);
                         ctr++;
                     } else {
-                        pdftex_warn
+                        luatex_warn
                             ("lua-loaded font %s char [U+%X] has an invalid ligature field!",
                              font_name(f), (int) i);
                     }
@@ -1475,7 +1338,7 @@ font_char_from_lua(lua_State * L, internal_font_number f, int i,
                     set_ligature_item(cligs[ctr], 0, end_ligature, 0);
                     set_charinfo_ligatures(co, cligs);
                 } else {
-                    pdftex_warn
+                    luatex_warn
                         ("lua-loaded font %s char [U+%X] has an invalid ligatures field!",
                          font_name(f), (int) i);
                 }
@@ -1499,89 +1362,91 @@ int font_from_lua(lua_State * L, int f)
     char *s;
     const char *ss;
     int *l_fonts = NULL;
-    int save_ref = 1;           /* unneeded, really */
+    int save_ref ;
     boolean no_math = false;
 
     /* will we save a cache of the luat table? */
-    s = string_field(L, "cache", "yes");
-    if (strcmp(s, "yes") == 0)
-        save_ref = 1;
-    else if (strcmp(s, "no") == 0)
+
+    save_ref = 1; /* we start with  ss = "yes" */
+    ss = NULL;
+    ss = n_string_field(L, lua_key_index(cache));
+    if (lua_key_eq(ss, no))
         save_ref = -1;
-    else if (strcmp(s, "renew") == 0)
+    else if (lua_key_eq(ss, renew))
         save_ref = 0;
-    free(s);
+    /* n_string_field leaves a value on stack*/
+    lua_pop(L,1); 
 
     /* the table is at stack index -1 */
-
-    if (luaS_width_index == 0)
+    /*if (luaS_width_index == 0)
         init_font_string_pointers(L);
-
-    s = string_field(L, "area", "");
+    */
+ 
+    s = n_string_field_copy(L,lua_key_index(area), "");
     set_font_area(f, s);
-    s = string_field(L, "filename", NULL);
+    s = n_string_field_copy(L, lua_key_index(filename), NULL);
     set_font_filename(f, s);
-    s = string_field(L, "encodingname", NULL);
+    s = n_string_field_copy(L, lua_key_index(encodingname), NULL);
     set_font_encodingname(f, s);
 
-    s = string_field(L, "name", NULL);
+    s = n_string_field_copy(L, lua_key_index(name), NULL);
     set_font_name(f, s);
-    s = string_field(L, "fullname", font_name(f));
+    s = n_string_field_copy(L, lua_key_index(fullname), font_name(f));
     set_font_fullname(f, s);
 
     if (s == NULL) {
-        pdftex_fail("lua-loaded font [%d] has no name!", f);
+        luatex_fail("lua-loaded font [%d] has no name!", f);
         return false;
     }
-    s = string_field(L, "psname", NULL);
+    s = n_string_field_copy(L, lua_key_index(psname), NULL);
     set_font_psname(f, s);
 
-    i = numeric_field(L, "units_per_em", 0);
+    i = lua_numeric_field_by_index(L,lua_key_index(units_per_em), 0);
     set_font_units_per_em(f, i);
-    i = numeric_field(L, "designsize", 655360);
+    i = lua_numeric_field_by_index(L,lua_key_index(designsize), 655360);
     set_font_dsize(f, i);
-    i = numeric_field(L, "size", font_dsize(f));
+    i = lua_numeric_field_by_index(L,lua_key_index(size), font_dsize(f));
     set_font_size(f, i);
-    i = numeric_field(L, "checksum", 0);
+    i = lua_numeric_field_by_index(L,lua_key_index(checksum), 0);
     set_font_checksum(f, (unsigned) i);
-    i = numeric_field(L, "direction", 0);
+    i = lua_numeric_field_by_index(L,lua_key_index(direction), 0);
     set_font_natural_dir(f, i);
-    i = numeric_field(L, "encodingbytes", 0);
+    i = lua_numeric_field_by_index(L,lua_key_index(encodingbytes), 0);
     set_font_encodingbytes(f, (char) i);
-    i = numeric_field(L, "tounicode", 0);
+    i = lua_numeric_field_by_index(L,lua_key_index(tounicode), 0);
     set_font_tounicode(f, (char) i);
 
-    i = numeric_field(L, "extend", 1000);
+    i = lua_numeric_field_by_index(L,lua_key_index(extend), 1000);
     if (i < FONT_EXTEND_MIN)
         i = FONT_EXTEND_MIN;
     if (i > FONT_EXTEND_MAX)
         i = FONT_EXTEND_MAX;
     set_font_extend(f, i);
-    i = numeric_field(L, "slant", 0);
+    i = lua_numeric_field_by_index(L,lua_key_index(slant), 0);
     if (i < FONT_SLANT_MIN)
         i = FONT_SLANT_MIN;
     if (i > FONT_SLANT_MAX)
         i = FONT_SLANT_MAX;
     set_font_slant(f, i);
 
-    i = numeric_field(L, "hyphenchar", int_par(default_hyphen_char_code));
+    i = lua_numeric_field_by_index(L,lua_key_index(hyphenchar), int_par(default_hyphen_char_code));
     set_hyphen_char(f, i);
-    i = numeric_field(L, "skewchar", int_par(default_skew_char_code));
+    i = lua_numeric_field_by_index(L,lua_key_index(skewchar), int_par(default_skew_char_code));
     set_skew_char(f, i);
-    i = boolean_field(L, "used", 0);
+    i = n_boolean_field(L, lua_key_index(used), 0);
     set_font_used(f, (char) i);
 
-    s = string_field(L, "attributes", NULL);
+    s = n_string_field_copy(L, lua_key_index(attributes), NULL);
     if (s != NULL && strlen(s) > 0) {
         i = maketexstring(s);
         set_pdf_font_attr(f, i);
     }
 
-    i = enum_field(L, "type", unknown_font_type, font_type_strings);
+    i = n_enum_field(L, lua_key_index(type), unknown_font_type, font_type_strings);
     set_font_type(f, i);
-    i = enum_field(L, "format", unknown_format, font_format_strings);
+    i = n_enum_field(L, lua_key_index(format), unknown_format, font_format_strings);
     set_font_format(f, i);
-    i = enum_field(L, "embedding", unknown_embedding, font_embedding_strings);
+    i = n_enum_field(L, lua_key_index(embedding), unknown_embedding, font_embedding_strings);
     set_font_embedding(f, i);
     if (font_encodingbytes(f) == 0 &&
         (font_format(f) == opentype_format
@@ -1590,16 +1455,16 @@ int font_from_lua(lua_State * L, int f)
     }
 
     /* now fetch the base fonts, if needed */
-    n = count_hash_items(L, luaS_index(fonts));
+    n = count_hash_items(L, lua_key_index(fonts));
     if (n > 0) {
         l_fonts = xmalloc((unsigned) ((unsigned) (n + 2) * sizeof(int)));
         memset(l_fonts, 0, (size_t) ((unsigned) (n + 2) * sizeof(int)));
-        lua_rawgeti(L, LUA_REGISTRYINDEX, luaS_index(fonts));
+        lua_rawgeti(L, LUA_REGISTRYINDEX, lua_key_index(fonts));
         lua_rawget(L, -2);
         for (i = 1; i <= n; i++) {
             lua_rawgeti(L, -1, i);
             if (lua_istable(L, -1)) {
-                lua_getfield(L, -1, "id");
+		lua_key_rawgeti(id);
                 if (lua_isnumber(L, -1)) {
                     l_fonts[i]=(int)lua_tonumber(L, -1);
                     lua_pop(L, 2);      /* pop id  and entry */
@@ -1609,17 +1474,18 @@ int font_from_lua(lua_State * L, int f)
             };
             ss = NULL;
             if (lua_istable(L, -1)) {
-                lua_getfield(L, -1, "name");
-                if (lua_isstring(L, -1)) {
-                    ss = lua_tostring(L, -1);
-                }
-                lua_pop(L, 1);  /* pop name */
+                /* lua_getfield(L, -1, "name"); */
+                /* if (lua_isstring(L, -1)) { */
+                /*     ss = lua_tostring(L, -1); */
+                /* } */
+                /* lua_pop(L, 1);  /\* pop name *\/ */
+		ss = n_string_field(L, lua_key_index(name));
             }
             if (ss != NULL) {
-                lua_getfield(L, -1, "size");
-                t = (lua_isnumber(L, -1) ? lua_roundnumber(L, -1) : -1000);
-                lua_pop(L, 1);
-
+                /* lua_getfield(L, -1, "size"); */
+                /* t = (lua_isnumber(L, -1) ? lua_roundnumber(L, -1) : -1000); */
+                /* lua_pop(L, 1); */
+	        t = lua_numeric_field_by_index(L, lua_key_index(size), -1000);
                 /* TODO: the stack is messed up, otherwise this
                  * explicit resizing would not be needed
                  */
@@ -1630,14 +1496,14 @@ int font_from_lua(lua_State * L, int f)
                     l_fonts[i] = find_font_id(ss, t);
                 lua_settop(L, s_top);
             } else {
-                pdftex_fail("Invalid local font in font %s!\n", font_name(f));
+                luatex_fail("Invalid local font in font %s!\n", font_name(f));
             }
             lua_pop(L, 1);      /* pop list entry */
         }
         lua_pop(L, 1);          /* pop list entry */
     } else {
         if (font_type(f) == virtual_font_type) {
-            pdftex_fail("Invalid local fonts in font %s!\n", font_name(f));
+            luatex_fail("Invalid local fonts in font %s!\n", font_name(f));
         } else {
             l_fonts = xmalloc(3 * sizeof(int));
             l_fonts[0] = 0;
@@ -1647,7 +1513,7 @@ int font_from_lua(lua_State * L, int f)
     }
 
     /* parameters */
-    no_math = boolean_field(L, "nomath", 0);
+    no_math = n_boolean_field(L, lua_key_index(nomath), 0);
     read_lua_parameters(L, f);
     if (!no_math) {
         read_lua_math_parameters(L, f);
@@ -1655,8 +1521,9 @@ int font_from_lua(lua_State * L, int f)
     read_lua_cidinfo(L, f);
 
     /* characters */
-
-    lua_getfield(L, -1, "characters");
+    //lua_rawgeti(L, LUA_REGISTRYINDEX, lua_key_index(characters));lua_rawget(L, -2);
+    lua_key_rawgeti(characters);
+     /*lua_getfield(L, -1, "characters");*/
     if (lua_istable(L, -1)) {
         /* find the array size values */
         int num = 0;            /* number of charinfo's to add */
@@ -1696,10 +1563,10 @@ int font_from_lua(lua_State * L, int f)
                     }
                 } else if (lua_isstring(L, -2)) {
                     const char *ss1 = lua_tostring(L, -2);
-                    if (luaS_ptr_eq(ss1, left_boundary)) {
+                    if (lua_key_eq(ss1, left_boundary)) {
                         font_char_from_lua(L, f, left_boundarychar, l_fonts,
                                            !no_math);
-                    } else if (luaS_ptr_eq(ss1, right_boundary)) {
+                    } else if (lua_key_eq(ss1, right_boundary)) {
                         font_char_from_lua(L, f, right_boundarychar, l_fonts,
                                            !no_math);
                     }
@@ -1711,15 +1578,15 @@ int font_from_lua(lua_State * L, int f)
             /* handle font expansion last: the |copy_font| routine is called eventually,
                and that needs to know |bc| and |ec|. */
             if (font_type(f) != virtual_font_type) {
-                int fstep = numeric_field(L, "step", 0);
+	        int fstep = lua_numeric_field_by_index(L, lua_key_index(step), 0);
                 if (fstep < 0)
                     fstep = 0;
                 if (fstep > 100)
                     fstep = 100;
                 if (fstep != 0) {
-                    int fshrink = numeric_field(L, "shrink", 0);
-                    int fstretch = numeric_field(L, "stretch", 0);
-                    int fexpand = boolean_field(L, "auto_expand", 0);
+		  int fshrink = lua_numeric_field_by_index(L, lua_key_index(shrink), 0);
+		  int fstretch =lua_numeric_field_by_index(L, lua_key_index(stretch), 0);
+		  int fexpand = n_boolean_field(L, lua_key_index(auto_expand), 0);
                     if (fshrink < 0)
                         fshrink = 0;
                     if (fshrink > 500)
@@ -1739,7 +1606,7 @@ int font_from_lua(lua_State * L, int f)
             }
 
         } else {                /* jikes, no characters */
-            pdftex_warn("lua-loaded font [%d] (%s) has no characters!", f,
+            luatex_warn("lua-loaded font [%d] (%s) has no characters!", f,
                         font_name(f));
         }
 
@@ -1751,7 +1618,7 @@ int font_from_lua(lua_State * L, int f)
             set_font_cache_id(f, save_ref);
         }
     } else {                    /* jikes, no characters */
-        pdftex_warn("lua-loaded font [%d] (%s) has no character table!", f,
+        luatex_warn("lua-loaded font [%d] (%s) has no character table!", f,
                     font_name(f));
     }
 
diff --git a/source/texk/web2c/luatexdir/font/mapfile.w b/source/texk/web2c/luatexdir/font/mapfile.w
index 9e0d342d9e37bf02b24052960b6cf8b861bbb26b..a8a9e4bcce79618e0610974acbb3017a3f96cc03 100644
--- a/source/texk/web2c/luatexdir/font/mapfile.w
+++ b/source/texk/web2c/luatexdir/font/mapfile.w
@@ -166,7 +166,7 @@ int avl_do_entry(fm_entry * fm, int mode)
     if (p != NULL) {
         switch (mode) {
         case FM_DUPIGNORE:
-            pdftex_warn
+            luatex_warn
                 ("fontmap entry for `%s' already exists, duplicates ignored",
                  fm->tfm_name);
             delete_new = 1;
@@ -174,7 +174,7 @@ int avl_do_entry(fm_entry * fm, int mode)
         case FM_REPLACE:
         case FM_DELETE:
             if (is_inuse(p)) {
-                pdftex_warn
+                luatex_warn
                     ("fontmap entry for `%s' has been used, replace/delete not allowed",
                      fm->tfm_name);
                 delete_new = 1;
@@ -222,7 +222,7 @@ static int check_fm_entry(fm_entry * fm, boolean warn)
 
     if (is_fontfile(fm) && !is_included(fm)) {
         if (warn)
-            pdftex_warn
+            luatex_warn
                 ("ambiguous entry for `%s': font file present but not included, "
                  "will be treated as font file not present", fm->tfm_name);
         xfree(fm->ff_name);
@@ -232,7 +232,7 @@ static int check_fm_entry(fm_entry * fm, boolean warn)
     /* if both ps_name and font file are missing, drop this entry */
     if (fm->ps_name == NULL && !is_fontfile(fm)) {
         if (warn)
-            pdftex_warn
+            luatex_warn
                 ("invalid entry for `%s': both ps_name and font file missing",
                  fm->tfm_name);
         a += 1;
@@ -241,7 +241,7 @@ static int check_fm_entry(fm_entry * fm, boolean warn)
     /* TrueType fonts cannot be reencoded without subsetting */
     if (is_truetype(fm) && is_reencoded(fm) && !is_subsetted(fm)) {
         if (warn)
-            pdftex_warn
+            luatex_warn
                 ("invalid entry for `%s': only subsetted TrueType font can be reencoded",
                  fm->tfm_name);
         a += 2;
@@ -250,14 +250,14 @@ static int check_fm_entry(fm_entry * fm, boolean warn)
     /* the value of SlantFont and ExtendFont must be reasonable */
     if (fm->slant < FONT_SLANT_MIN || fm->slant > FONT_SLANT_MAX) {
         if (warn)
-            pdftex_warn
+            luatex_warn
                 ("invalid entry for `%s': too big value of SlantFont (%g)",
                  fm->tfm_name, fm->slant / 1000.0);
         a += 8;
     }
     if (fm->extend < FONT_EXTEND_MIN || fm->extend > FONT_EXTEND_MAX) {
         if (warn)
-            pdftex_warn
+            luatex_warn
                 ("invalid entry for `%s': too big value of ExtendFont (%g)",
                  fm->tfm_name, fm->extend / 1000.0);
         a += 16;
@@ -267,7 +267,7 @@ static int check_fm_entry(fm_entry * fm, boolean warn)
     if (fm->pid != -1 &&
         !(is_truetype(fm) && is_subsetted(fm) && !is_reencoded(fm))) {
         if (warn)
-            pdftex_warn
+            luatex_warn
                 ("invalid entry for `%s': PidEid can be used only with subsetted non-reencoded TrueType fonts",
                  fm->tfm_name);
         a += 32;
@@ -406,7 +406,7 @@ static void fm_scan_line(void)
                         for (r = s; *r != ' ' && *r != '"' && *r != '\0'; r++); /* jump over name */
                         c = *r; /* remember char for temporary end of string */
                         *r = '\0';
-                        pdftex_warn
+                        luatex_warn
                             ("invalid entry for `%s': unknown name `%s' ignored",
                              fm->tfm_name, s);
                         *r = (char) c;
@@ -418,7 +418,7 @@ static void fm_scan_line(void)
             if (*r == '"')      /* closing quote */
                 r++;
             else {
-                pdftex_warn
+                luatex_warn
                     ("invalid entry for `%s': closing quote missing",
                      fm->tfm_name);
                 goto bad_line;
@@ -528,14 +528,14 @@ static void fm_read_info(void)
                             fm_file = NULL;
                         }
                     } else {
-                        pdftex_warn("cannot open font map file (%s)", cur_file_name);
+                        luatex_warn("cannot open font map file (%s)", cur_file_name);
                     }
                 } else {
-                    pdftex_warn("cannot open font map file (%s)", cur_file_name);
+                    luatex_warn("cannot open font map file (%s)", cur_file_name);
                 }
             } else {
                 if (!fm_open(cur_file_name)) {
-                    pdftex_warn("cannot open font map file (%s)", cur_file_name);
+                    luatex_warn("cannot open font map file (%s)", cur_file_name);
                 } else {
                     fm_read_file();
                     tex_printf("{%s", cur_file_name);
@@ -552,7 +552,7 @@ static void fm_read_info(void)
         }
         break;
     case MAPLINE:
-        cur_file_name = NULL;   /* makes pdftex_warn() shorter */
+        cur_file_name = NULL;   /* makes luatex_warn() shorter */
         fm_scan_line();
         break;
     default:
diff --git a/source/texk/web2c/luatexdir/font/pkin.w b/source/texk/web2c/luatexdir/font/pkin.w
index 69812fc6964cbfdfac5aed19f280d0531c5bf5e6..f3609fe3b1b79f97dd4cd239c6233d6a4bce57bc 100644
--- a/source/texk/web2c/luatexdir/font/pkin.w
+++ b/source/texk/web2c/luatexdir/font/pkin.w
@@ -65,7 +65,7 @@ static shalfword pkbyte(void)
     register shalfword i;
     i = t3_getchar();
     if (t3_eof())
-        pdftex_fail("unexpected eof in pk file");
+        luatex_fail("unexpected eof in pk file");
     return (i);
 }
 
@@ -202,7 +202,7 @@ static halfword rest(void)
             return (i);
         }
     } else {
-        pdftex_fail("shouldn't happen");
+        luatex_fail("shouldn't happen");
         return 0;
      /*NOTREACHED*/}
 }
@@ -321,7 +321,7 @@ static void unpack(chardesc * cd)
             turnon = !turnon;
         }
         if ((rowsleft != 0) || ((int) hbit != cd->cwidth))
-            pdftex_fail("error while unpacking; more bits than required");
+            luatex_fail("error while unpacking; more bits than required");
     }
 }
 
@@ -343,9 +343,9 @@ int readchar(boolean check_preamble, chardesc * cd)
  */
     if (check_preamble) {
         if (pkbyte() != 247)
-            pdftex_fail("bad pk file, expected pre");
+            luatex_fail("bad pk file, expected pre");
         if (pkbyte() != 89)
-            pdftex_fail("bad version of pk file");
+            luatex_fail("bad version of pk file");
         for (i = pkbyte(); i > 0; i--)  /* creator of pkfile */
             (void) pkbyte();
         (void) pkquad();        /* design size */
@@ -401,7 +401,7 @@ int readchar(boolean check_preamble, chardesc * cd)
                 cd->yoff = pkquad();
             }
             if (length <= 0)
-                pdftex_fail("packet length (%i) too small", (int) length);
+                luatex_fail("packet length (%i) too small", (int) length);
             unpack(cd);
             return 1;
         } else {
@@ -426,7 +426,7 @@ int readchar(boolean check_preamble, chardesc * cd)
             case 246:
                 break;
             default:
-                pdftex_fail("unexpected command (%i)", (int) flagbyte);
+                luatex_fail("unexpected command (%i)", (int) flagbyte);
             }
         }
     }
diff --git a/source/texk/web2c/luatexdir/font/sfnt.h b/source/texk/web2c/luatexdir/font/sfnt.h
index 9b5470e7bbcec93b2615f644320a1179a7031651..d99eb0dd4c6f624693893d0841c00a324b4bf346 100644
--- a/source/texk/web2c/luatexdir/font/sfnt.h
+++ b/source/texk/web2c/luatexdir/font/sfnt.h
@@ -183,7 +183,7 @@ typedef struct {
 #    define RELEASE(a) free(a)
 #    define NEW(a,b) xmalloc((unsigned)((unsigned)(a)*sizeof(b)))
 #    define RENEW(a,b,c) xrealloc(a, (unsigned)((unsigned)(b)*sizeof(c)))
-#    define TT_ERROR pdftex_fail
+#    define TT_ERROR luatex_fail
 #    define WARN printf
 
 
diff --git a/source/texk/web2c/luatexdir/font/subfont.w b/source/texk/web2c/luatexdir/font/subfont.w
index 1a2964cd2fe902119b33e35d8012433d8edcaf47..1ac2d119f1abd80e75f02005e54738d12921ff74 100644
--- a/source/texk/web2c/luatexdir/font/subfont.w
+++ b/source/texk/web2c/luatexdir/font/subfont.w
@@ -105,7 +105,7 @@ static void sfd_getline(boolean expect_eof)
         if (expect_eof)
             return;
         else
-            pdftex_fail("unexpected end of file");
+            luatex_fail("unexpected end of file");
     }
     p = sfd_line;
     do {
@@ -149,13 +149,13 @@ static sfd_entry *read_sfd(char *sfd_name)
             if (!(run_callback(callback_id, "S->bSd", cur_file_name,
                                &file_opened, &sfd_buffer, &sfd_size) &&
                   file_opened && sfd_size > 0)) {
-                pdftex_warn("cannot open SFD file for reading (%s)", cur_file_name);
+                luatex_warn("cannot open SFD file for reading (%s)", cur_file_name);
                 cur_file_name = NULL;
                 return NULL;
             }
         } else {
             if (!sfd_open(cur_file_name)) {
-                pdftex_warn("cannot open SFD file for reading (%s)", cur_file_name);
+                luatex_warn("cannot open SFD file for reading (%s)", cur_file_name);
                 cur_file_name = NULL;
                 return NULL;
             }
@@ -187,16 +187,16 @@ static sfd_entry *read_sfd(char *sfd_name)
             } else if (*p == 0) /* end of subfont */
                 break;
             if (sscanf(p, " %li %n", &i, &n) == 0)
-                pdftex_fail("invalid token:\n%s", p);
+                luatex_fail("invalid token:\n%s", p);
             p += n;
             if (*p == ':') {    /* offset */
                 k = i;
                 p++;
             } else if (*p == '_') {     /* range */
                 if (sscanf(p + 1, " %li %n", &j, &n) == 0)
-                    pdftex_fail("invalid token:\n%s", p);
+                    luatex_fail("invalid token:\n%s", p);
                 if (i > j || k + (j - i) > 255)
-                    pdftex_fail("invalid range:\n%s", p);
+                    luatex_fail("invalid range:\n%s", p);
                 while (i <= j)
                     sf->charcodes[k++] = i++;
                 p += n + 1;
diff --git a/source/texk/web2c/luatexdir/font/texfont.w b/source/texk/web2c/luatexdir/font/texfont.w
index 32be55eff77765d85519ac14685f69dba04b23b7..6771934aa8e0f8b13acdd8892f91e1b92090297d 100644
--- a/source/texk/web2c/luatexdir/font/texfont.w
+++ b/source/texk/web2c/luatexdir/font/texfont.w
@@ -196,7 +196,7 @@ static void set_charinfo(internal_font_number f, int c, charinfo * ci)
         if (glyph) {
             font_tables[f]->charinfo[glyph] = *ci;
         } else {
-            pdftex_fail("font: %s", "character insertion failed");
+            luatex_fail("font: %s", "character insertion failed");
         }
     } else if (c == left_boundarychar) {
         set_left_boundary(f, ci);
diff --git a/source/texk/web2c/luatexdir/font/tounicode.w b/source/texk/web2c/luatexdir/font/tounicode.w
index d2e9e765e0607de0e252bfbebd9a9bbea212a92c..587a824eea03ad1ab1ccc5cd0e69292eeb55d7b1 100644
--- a/source/texk/web2c/luatexdir/font/tounicode.w
+++ b/source/texk/web2c/luatexdir/font/tounicode.w
@@ -99,7 +99,7 @@ void def_tounicode(str_number glyph, str_number unistr)
     }
     if (l == 0 || valid_unistr == 0 || strlen(buf) == 0
         || strcmp(buf, notdef) == 0) {
-        pdftex_warn("ToUnicode: invalid parameter(s): `%s' => `%s'", buf, p);
+        luatex_warn("ToUnicode: invalid parameter(s): `%s' => `%s'", buf, p);
         return;
     }
     if (glyph_unicode_tree == NULL) {
@@ -311,7 +311,7 @@ int write_tounicode(PDF pdf, char **glyph_names, char *name)
     assert(strlen(name) + strlen(builtin_suffix) < SMALL_BUF_SIZE);
     if (glyph_unicode_tree == NULL) {
 #ifdef DEBUG
-        pdftex_warn("no GlyphToUnicode entry has been inserted yet!");
+        luatex_warn("no GlyphToUnicode entry has been inserted yet!");
 #endif
         pdf->gen_tounicode = 0;
         return 0;
diff --git a/source/texk/web2c/luatexdir/font/vfovf.w b/source/texk/web2c/luatexdir/font/vfovf.w
index 69f99fab036a17d5d39015eb91752ce411693d25..89e420aa1f70414db25baa1e82307e9b7da103c1 100644
--- a/source/texk/web2c/luatexdir/font/vfovf.w
+++ b/source/texk/web2c/luatexdir/font/vfovf.w
@@ -133,7 +133,7 @@ typedef struct vf_stack_record {
 {                                                      \
   eight_bits vf_tmp_b;				       \
     if (vf_cur >= vf_size) {                           \
-        pdftex_fail("unexpected eof on virtual font"); \
+        luatex_fail("unexpected eof on virtual font"); \
     }                                                  \
     vf_tmp_b = vf_buffer[vf_cur++];                    \
     a = vf_tmp_b;                                      \
diff --git a/source/texk/web2c/luatexdir/font/writecff.w b/source/texk/web2c/luatexdir/font/writecff.w
index 57e9374d175001b20ea58967028ef26b217aefe9..c68ed576e35649071bcc0b09b32681d10d6307be 100644
--- a/source/texk/web2c/luatexdir/font/writecff.w
+++ b/source/texk/web2c/luatexdir/font/writecff.w
@@ -51,9 +51,9 @@ static unsigned long get_unsigned(cff_font * cff, int n)
 }
 
 @ @c
-#define CFF_ERROR pdftex_fail
+#define CFF_ERROR luatex_fail
 #undef WARN
-#define WARN pdftex_warn
+#define WARN luatex_warn
 
 const char *const cff_stdstr[CFF_STDSTR_MAX] = {
     ".notdef", "space", "exclam", "quotedbl", "numbersign",
@@ -863,7 +863,7 @@ cff_dict *cff_dict_unpack(card8 * data, card8 * endptr)
     }
 
     if (status != CFF_PARSE_OK) {
-        pdftex_fail("Parsing CFF DICT failed. (error=%d)", status);
+        luatex_fail("Parsing CFF DICT failed. (error=%d)", status);
     } else if (stack_top != 0) {
         WARN("Garbage in CFF DICT data.");
         stack_top = 0;
@@ -899,13 +899,13 @@ double cff_dict_get(cff_dict * dict, const char *key, int idx)
            if ((dict->entries)[i].count > idx)
                 value = (dict->entries)[i].values[idx];
             else
-                pdftex_fail("Invalid index number.");
+                luatex_fail("Invalid index number.");
             break;
         }
     }
 
     if (i == dict->count)
-        pdftex_fail("DICT entry \"%s\" not found.", key);
+        luatex_fail("DICT entry \"%s\" not found.", key);
 
     return value;
 }
@@ -1122,7 +1122,7 @@ cff_font *read_cff(unsigned char *buf, long buflength, int n)
         return NULL;
     }
     if (cff->header_major > 1) {
-        pdftex_warn("CFF major version %u not supported.", cff->header_major);
+        luatex_warn("CFF major version %u not supported.", cff->header_major);
         cff_close(cff);
         return NULL;
     }
@@ -1131,7 +1131,7 @@ cff_font *read_cff(unsigned char *buf, long buflength, int n)
     /* Name INDEX */
     idx = cff_get_index(cff);
     if (n > idx->count - 1) {
-        pdftex_warn("Invalid CFF fontset index number.");
+        luatex_warn("Invalid CFF fontset index number.");
         cff_close(cff);
         return NULL;
     }
@@ -1540,7 +1540,7 @@ void cff_dict_set(cff_dict * dict, const char *key, int idx, double value)
     }
 
     if (i == dict->count)
-        pdftex_fail("DICT entry \"%s\" not found.", key);
+        luatex_fail("DICT entry \"%s\" not found.", key);
 }
 
 
@@ -3014,7 +3014,7 @@ static void write_fontfile(PDF pdf, cff_font * cffont, char *fullname)
   if ((avl_find(fd->gl_tree,glyph) != NULL)) {                                 \
       size = (long)(cs_idx->offset[code+1] - cs_idx->offset[code]);	\
     if (size > CS_STR_LEN_MAX) {                                               \
-      pdftex_fail("Charstring too long: gid=%u, %ld bytes", code, size);       \
+      luatex_fail("Charstring too long: gid=%u, %ld bytes", code, size);       \
     }                                                                          \
     if (charstring_len + CS_STR_LEN_MAX >= max_len) {                          \
 	max_len = (long)(charstring_len + 2 * CS_STR_LEN_MAX);		\
@@ -3457,7 +3457,7 @@ void write_cid_cff(PDF pdf, cff_font * cffont, fd_entry * fd)
                               (CIDToGIDMap[2 * cid + 1]));
         size = (long) (cs_idx->offset[gid_org + 1] - cs_idx->offset[gid_org]);
         if (size > CS_STR_LEN_MAX) {
-            pdftex_fail("Charstring too long: gid=%u, %ld bytes", cid, size);
+            luatex_fail("Charstring too long: gid=%u, %ld bytes", cid, size);
         }
         if (charstring_len + CS_STR_LEN_MAX >= max_len) {
             max_len = charstring_len + 2 * CS_STR_LEN_MAX;
diff --git a/source/texk/web2c/luatexdir/font/writefont.w b/source/texk/web2c/luatexdir/font/writefont.w
index a7c0f337ab9e2a5d078e41f795aa4c830f6dbf3d..15763c3b4b2d3f0aa4d3492ab6995101370f2222 100644
--- a/source/texk/web2c/luatexdir/font/writefont.w
+++ b/source/texk/web2c/luatexdir/font/writefont.w
@@ -525,7 +525,7 @@ static void write_fontdescriptor(PDF pdf, fd_entry * fd)
         fd_flags = is_std_t1font(fd->fm)
             ? std_flags[check_std_t1font(fd->fm->ps_name)]
             : FD_FLAGS_DEFAULT_NON_EMBED;
-        pdftex_warn
+        luatex_warn
             ("No flags specified for non-embedded font `%s' (%s) (I'm using %i): "
              "fix your map entry.",
              fd->fm->ps_name != NULL ? fd->fm->ps_name : "No name given",
@@ -716,7 +716,7 @@ static void create_fontdictionary(PDF pdf, internal_font_number f)
         create_fontdescriptor(fo, f);
         write_fontdescriptor(pdf, fo->fd);
         if (!is_std_t1font(fo->fm))
-            pdftex_warn("font `%s' is not a standard font; "
+            luatex_warn("font `%s' is not a standard font; "
                         "I suppose it is available to your PDF viewer then",
                         fo->fm->ps_name);
     }
@@ -780,7 +780,7 @@ void do_pdf_font(PDF pdf, internal_font_number f)
                 fm->ff_name = s;
                 del_file = 1;
             } else {
-                pdftex_fail
+                luatex_fail
                     ("writefont.c: The file (%s) does not contain font `%s'",
                      fm->ff_name, fm->ps_name);
             }
@@ -808,7 +808,7 @@ void do_pdf_font(PDF pdf, internal_font_number f)
             set_type1(fm);
             break;
         default:
-            pdftex_fail
+            luatex_fail
                 ("writefont.c: The file format (%s) for font `%s' is incompatible with wide characters\n",
                  font_format_name(f), font_name(f));
         }
diff --git a/source/texk/web2c/luatexdir/font/writet1.w b/source/texk/web2c/luatexdir/font/writet1.w
index 527e1f6c5a71667f926f03f6aac99ed813e80982..af77b0013a58671a9df2773ce920c319a26b2b38 100644
--- a/source/texk/web2c/luatexdir/font/writet1.w
+++ b/source/texk/web2c/luatexdir/font/writet1.w
@@ -257,7 +257,7 @@ static void enc_getline(void)
     char c;
   restart:
     if (enc_eof())
-        pdftex_fail("unexpected end of file");
+        luatex_fail("unexpected end of file");
     p = enc_line;
     do {
         c = (char) enc_getchar();
@@ -283,7 +283,7 @@ char **load_enc_file(char *enc_name)
     cur_file_name = luatex_find_file(enc_name, find_enc_file_callback);
 
     if (cur_file_name == NULL) {
-        pdftex_fail("cannot find encoding file '%s' for reading", enc_name);
+        luatex_fail("cannot find encoding file '%s' for reading", enc_name);
     }
     callback_id = callback_defined(read_enc_file_callback);
     enc_curbyte = 0;
@@ -292,12 +292,12 @@ char **load_enc_file(char *enc_name)
         if (run_callback(callback_id, "S->bSd", cur_file_name,
                          &file_opened, &enc_buffer, &enc_size)) {
             if ((!file_opened) || enc_size == 0) {
-                pdftex_fail("cannot open encoding file '%s' for reading", cur_file_name);
+                luatex_fail("cannot open encoding file '%s' for reading", cur_file_name);
             }
         }
     } else {
         if (!enc_open(cur_file_name)) {
-            pdftex_fail("cannot open encoding file '%s' for reading", cur_file_name);
+            luatex_fail("cannot open encoding file '%s' for reading", cur_file_name);
         }
         enc_read_file();
         enc_close();
@@ -311,7 +311,7 @@ char **load_enc_file(char *enc_name)
     enc_getline();
     if (*enc_line != '/' || (r = strchr(enc_line, '[')) == NULL) {
         remove_eol(r, enc_line);
-        pdftex_fail
+        luatex_fail
             ("invalid encoding vector (a name or `[' missing): `%s'", enc_line);
     }
     names_count = 0;
@@ -324,7 +324,7 @@ char **load_enc_file(char *enc_name)
             *p = 0;
             skip(r, ' ');
             if (names_count >= 256)
-                pdftex_fail("encoding vector contains more than 256 names");
+                luatex_fail("encoding vector contains more than 256 names");
             if (strcmp(buf, notdef) != 0)
                 glyph_names[names_count] = xstrdup(buf);
             names_count++;
@@ -334,7 +334,7 @@ char **load_enc_file(char *enc_name)
                 goto done;
             else {
                 remove_eol(r, enc_line);
-                pdftex_fail
+                luatex_fail
                     ("invalid encoding vector: a name or `] def' expected: `%s'",
                      enc_line);
             }
@@ -376,7 +376,7 @@ static int t1_getbyte(void)
         return c;
     if (t1_block_length == 0) {
         if (c != 128)
-            pdftex_fail("invalid marker");
+            luatex_fail("invalid marker");
         c = t1_getchar();
         if (c == 3) {
             while (!t1_eof())
@@ -456,7 +456,7 @@ static float t1_scan_num(char *p, char **r)
     skip(p, ' ');
     if (sscanf(p, "%g", &f) != 1) {
         remove_eol(p, t1_line_array);
-        pdftex_fail("a number expected: `%s'", t1_line_array);
+        luatex_fail("a number expected: `%s'", t1_line_array);
     }
     if (r != NULL) {
         for (; isdigit(*p) || *p == '.' ||
@@ -488,7 +488,7 @@ static void t1_getline(void)
     static int eexec_len = 17;  /* |strlen(eexec_str)| */
   restart:
     if (t1_eof())
-        pdftex_fail("unexpected end of file");
+        luatex_fail("unexpected end of file");
     t1_line_ptr = t1_line_array;
     alloc_array(t1_line, 1, T1_BUF_SIZE);
     t1_cslen = 0;
@@ -605,7 +605,7 @@ static void t1_check_block_len(boolean decrypt)
         c = edecrypt((byte) c);
     l = (int) t1_block_length;
     if (!(l == 0 && (c == 10 || c == 13))) {
-        pdftex_fail("%i bytes more than expected were ignored", l + 1);
+        luatex_fail("%i bytes more than expected were ignored", l + 1);
     }
 }
 
@@ -642,7 +642,7 @@ static void t1_stop_eexec(PDF pdf)
             if (last_hexbyte == 0)
                 t1_puts(pdf, "00");
             else
-                pdftex_fail("unexpected data after eexec");
+                luatex_fail("unexpected data after eexec");
         }
     }
     t1_cs = false;
@@ -680,7 +680,7 @@ static void t1_scan_keys(PDF pdf)
     if (t1_prefix("/FontType")) {
         p = t1_line_array + strlen("FontType") + 1;
         if ((i = (int) t1_scan_num(p, 0)) != 1)
-            pdftex_fail("Type%d fonts unsupported by pdfTeX", i);
+            luatex_fail("Type%d fonts unsupported by pdfTeX", i);
         return;
     }
     for (key = (const key_entry *) font_key; key - font_key < FONT_KEYS_NUM;
@@ -696,7 +696,7 @@ static void t1_scan_keys(PDF pdf)
     if ((k = (int) (key - font_key)) == FONTNAME_CODE) {
         if (*p != '/') {
             remove_eol(p, t1_line_array);
-            pdftex_fail("a name expected: `%s'", t1_line_array);
+            luatex_fail("a name expected: `%s'", t1_line_array);
         }
         r = ++p;                /* skip the slash */
         for (q = t1_buf_array; *p != ' ' && *p != 10; *q++ = *p++);
@@ -738,7 +738,7 @@ static void t1_scan_param(PDF pdf)
     if (t1_prefix(lenIV)) {
         t1_lenIV = (short) t1_scan_num(t1_line_array + strlen(lenIV), 0);
         if (t1_lenIV < 0)
-            pdftex_fail("negative value of lenIV is not supported");
+            luatex_fail("negative value of lenIV is not supported");
         return;
     }
     t1_scan_keys(pdf);
@@ -776,7 +776,7 @@ static char **t1_builtin_enc(void)
             }
             return glyph_names;
         } else
-            pdftex_fail
+            luatex_fail
                 ("cannot subset font (unknown predefined encoding `%s')",
                  t1_buf_array);
     }
@@ -808,7 +808,7 @@ static char **t1_builtin_enc(void)
                 *p = 0;
                 skip(r, ' ');
                 if (counter > 255)
-                    pdftex_fail("encoding vector contains more than 256 names");
+                    luatex_fail("encoding vector contains more than 256 names");
                 if (strcmp(t1_buf_array, notdef) != 0)
                     glyph_names[counter] = xstrdup(t1_buf_array);
                 counter++;
@@ -818,7 +818,7 @@ static char **t1_builtin_enc(void)
                     break;
                 else {
                     remove_eol(r, t1_line_array);
-                    pdftex_fail
+                    luatex_fail
                         ("a name or `] def' or `] readonly def' expected: `%s'",
                          t1_line_array);
                 }
@@ -906,13 +906,13 @@ static boolean t1_open_fontfile(const char *open_name_prefix)
     t1_size = 0;
     ff = check_ff_exist(fd_cur->fm->ff_name, is_truetype(fd_cur->fm));
     if (ff->ff_path == NULL) {
-        pdftex_fail("cannot open Type 1 font file for reading (%s)",
+        luatex_fail("cannot open Type 1 font file for reading (%s)",
                     fd_cur->fm->ff_name);
         return false;
     }
     cur_file_name = luatex_find_file(ff->ff_path, find_type1_file_callback);
     if (cur_file_name == NULL) {
-        pdftex_fail("cannot open Type 1 font file for reading (%s)",
+        luatex_fail("cannot open Type 1 font file for reading (%s)",
                     ff->ff_path);
         return false;
     }
@@ -921,7 +921,7 @@ static boolean t1_open_fontfile(const char *open_name_prefix)
         if (!run_callback(callback_id, "S->bSd", cur_file_name,
                           &file_opened, &t1_buffer, &t1_size)
             && file_opened && t1_size > 0) {
-            pdftex_warn("cannot open Type 1 font file for reading (%s)",
+            luatex_warn("cannot open Type 1 font file for reading (%s)",
                         cur_file_name);
             return false;
         }
@@ -972,7 +972,7 @@ static void t1_include(PDF pdf)
 @c
 #define check_subr(subr) \
     if (subr >= subr_size || subr < 0) \
-        pdftex_fail("Subrs array: entry index out of range (%i)",  subr);
+        luatex_fail("Subrs array: entry index out of range (%i)",  subr);
 
 static const char **check_cs_token_pair(void)
 {
@@ -998,7 +998,7 @@ static void cs_store(boolean is_subr)
     } else {
         ptr = cs_ptr++;
         if (cs_ptr - cs_tab > cs_size)
-            pdftex_fail
+            luatex_fail
                 ("CharStrings dict: more entries than dict size (%i)", cs_size);
         if (strcmp(t1_buf_array + 1, notdef) == 0)      /* skip the slash */
             ptr->name = (char *) notdef;
@@ -1040,7 +1040,7 @@ static boolean is_cc_init = false;
     stack_ptr -= N
 
 #define stack_error(N) {                \
-    pdftex_fail("CharString: invalid access (%i) to stack (%i entries)", \
+    luatex_fail("CharString: invalid access (%i) to stack (%i entries)", \
                  (int) N, (int)(stack_ptr - cc_stack));                  \
     goto cs_error;                    \
 }
@@ -1110,9 +1110,9 @@ static void cs_fail(const char *cs_name, int subr, const char *fmt, ...)
     vsprintf(buf, fmt, args);
     va_end(args);
     if (cs_name == NULL)
-        pdftex_fail("Subr (%i): %s", (int) subr, buf);
+        luatex_fail("Subr (%i): %s", (int) subr, buf);
     else
-        pdftex_fail("CharString (/%s): %s", cs_name, buf);
+        luatex_fail("CharString (/%s): %s", cs_name, buf);
 }
 
 @ fix a return-less subr by appending |CS_RETURN|
@@ -1176,7 +1176,7 @@ static void cs_mark(const char *cs_name, int subr)
                 if (strcmp(ptr->name, cs_name) == 0)
                     break;
             if (ptr == cs_ptr) {
-                pdftex_warn("glyph `%s' undefined", cs_name);
+                luatex_warn("glyph `%s' undefined", cs_name);
                 return;
             }
             if (ptr->name == notdef)
@@ -1282,7 +1282,7 @@ static void cs_mark(const char *cs_name, int subr)
         }
     }
     if (cs_name == NULL && last_cmd != CS_RETURN) {
-        pdftex_warn("last command in subr `%i' is not a RETURN; "
+        luatex_warn("last command in subr `%i' is not a RETURN; "
                     "I will add it now but please consider fixing the font",
                     (int) subr);
         append_cs_return(ptr);
@@ -1670,7 +1670,7 @@ static void t1_subset_charstrings(PDF pdf)
     t1_mark_glyphs();
     if (subr_tab != NULL) {
         if (cs_token_pair == NULL)
-            pdftex_fail
+            luatex_fail
                 ("This Type 1 font uses mismatched subroutine begin/end token pairs.");
         t1_subr_flush();
     }
diff --git a/source/texk/web2c/luatexdir/font/writet3.w b/source/texk/web2c/luatexdir/font/writet3.w
index 89f6d86ec415bc82f3299cedf15f8b24559ae563..773b59598ac0cb03660fb9ef2d5025ad715d755d 100644
--- a/source/texk/web2c/luatexdir/font/writet3.w
+++ b/source/texk/web2c/luatexdir/font/writet3.w
@@ -50,7 +50,7 @@ int t3_curbyte = 0;
 
 #define t3_check_eof()                                     \
     if (t3_eof())                                          \
-        pdftex_fail("unexpected end of file");
+        luatex_fail("unexpected end of file");
 
 @
 @c
@@ -141,7 +141,7 @@ static boolean writepk(PDF pdf, internal_font_number f)
         if (name == NULL ||
             !FILESTRCASEEQ(cur_file_name, font_ret.name) ||
             !kpse_bitmap_tolerance((float) font_ret.dpi, (float) dpi)) {
-            pdftex_fail("Font %s at %i not found", cur_file_name, (int) dpi);
+            luatex_fail("Font %s at %i not found", cur_file_name, (int) dpi);
         }
     }
     callback_id = callback_defined(read_pk_file_callback);
@@ -150,7 +150,7 @@ static boolean writepk(PDF pdf, internal_font_number f)
             (run_callback
              (callback_id, "S->bSd", name, &file_opened, &t3_buffer, &t3_size)
              && file_opened && t3_size > 0)) {
-            pdftex_warn("Font %s at %i not found", cur_file_name, (int) dpi);
+            luatex_warn("Font %s at %i not found", cur_file_name, (int) dpi);
             cur_file_name = NULL;
             return false;
         }
diff --git a/source/texk/web2c/luatexdir/font/writettf.w b/source/texk/web2c/luatexdir/font/writettf.w
index 16585faea1ca8651fc32c5754893d0c31463cc98..e98d567c8ddc60d2a6eae0267bad2ba00c45a07b 100644
--- a/source/texk/web2c/luatexdir/font/writettf.w
+++ b/source/texk/web2c/luatexdir/font/writettf.w
@@ -487,7 +487,7 @@ long ttf_getnum(int s)
     int c;
     while (s > 0) {
         if (ttf_eof())
-            pdftex_fail("unexpected EOF");
+            luatex_fail("unexpected EOF");
         c = ttf_getchar();
         i = (i << 8) + c;
         s--;
@@ -517,7 +517,7 @@ dirtab_entry *ttf_name_lookup(const char *s, boolean required)
             break;
     if (tab - dir_tab == ntabs) {
         if (required)
-            pdftex_fail("can't find table `%s'", s);
+            luatex_fail("can't find table `%s'", s);
         else
             tab = NULL;
     }
@@ -587,7 +587,7 @@ static void ttf_copy_encoding(void)
             e = ttfenc_tab + *q;
             e->code = charcodes[*q];
             if (e->code == -1)
-                pdftex_warn
+                luatex_warn
                     ("character %i in subfont %s is not mapped to any charcode",
                      *q, fd_cur->fm->tfm_name);
             else {
@@ -817,7 +817,7 @@ void ttf_read_post(void)
         }
         break;
     default:
-        pdftex_warn("unsupported format (%.8X) of `post' table, assuming 3.0",
+        luatex_warn("unsupported format (%.8X) of `post' table, assuming 3.0",
                     (unsigned int) post_format);
     case 0x00030000:
         for (glyph = glyph_tab; glyph - glyph_tab < NMACGLYPHS; glyph++) {
@@ -893,13 +893,13 @@ static ttf_cmap_entry *ttf_read_cmap(char *ttf_name, int pid, int eid,
                 goto read_cmap_format_4;
             else {
                 if (warn)
-                    pdftex_warn("cmap format %i unsupported", format);
+                    luatex_warn("cmap format %i unsupported", format);
                 return NULL;
             }
         }
     }
     if (warn)
-        pdftex_warn("cannot find cmap subtable for (pid,eid) = (%i, %i)",
+        luatex_warn("cannot find cmap subtable for (pid,eid) = (%i, %i)",
                     pid, eid);
     return NULL;
   read_cmap_format_4:
@@ -950,10 +950,10 @@ static ttf_cmap_entry *ttf_read_cmap(char *ttf_name, int pid, int eid,
                         index = (index + s->idDelta) & 0xFFFF;
                 }
                 if (index >= glyphs_count)
-                    pdftex_fail("cmap: glyph index %li out of range [0..%i)",
+                    luatex_fail("cmap: glyph index %li out of range [0..%i)",
                                 index, glyphs_count);
                 if (p->table[i] != -1)
-                    pdftex_warn
+                    luatex_warn
                         ("cmap: multiple glyphs are mapped to unicode %.4lX, "
                          "only %li will be used (glyph %li being ignored)", i,
                          p->table[i], index);
@@ -999,7 +999,7 @@ static void ttf_reset_chksm(PDF pdf, dirtab_entry * tab)
     tmp_ulong = 0;
     tab->offset = (TTF_ULONG) ttf_offset();
     if (tab->offset % 4 != 0)
-        pdftex_warn("offset of `%4.4s' is not a multiple of 4", tab->tag);
+        luatex_warn("offset of `%4.4s' is not a multiple of 4", tab->tag);
 }
 
 
@@ -1035,7 +1035,7 @@ static void ttf_byte_encoding(PDF pdf)
             put_byte(e->newindex);
         } else {
             if (e->name != notdef)
-                pdftex_warn
+                luatex_warn
                     ("glyph `%s' has been mapped to `%s' in `ttf_byte_encoding' cmap table",
                      e->name, notdef);
             put_byte(0);        /* notdef */
@@ -1124,7 +1124,7 @@ static void ttf_write_cmap(PDF pdf)
             offset += TRIMMED_TABLE_MAP_LENGTH;
             break;
         default:
-            pdftex_fail("invalid format (it should not have happened)");
+            luatex_fail("invalid format (it should not have happened)");
         }
         (void) put_ushort(ce->platform_id);
         (void) put_ushort(ce->encoding_id);
@@ -1268,7 +1268,7 @@ static void ttf_write_dirtab(PDF pdf)
         }
     }
     if (i % 4 != 0) {
-        pdftex_warn("font length is not a multiple of 4 (%li)", i);
+        luatex_warn("font length is not a multiple of 4 (%li)", i);
         checksum <<= 8 * (4 - i % 4);
     }
     k = 0xB1B0AFBA - checksum;
@@ -1365,7 +1365,7 @@ static void ttf_reindex_glyphs(void)
             t = cmap->table;
             assert(t != NULL && e->code < 0x10000);
             if (t[e->code] < 0) {
-                pdftex_warn
+                luatex_warn
                     ("subfont %s: wrong mapping: character %li --> 0x%4.4lX --> .notdef",
                      fd_cur->fm->tfm_name, (long) (e - ttfenc_tab), e->code);
                 continue;
@@ -1381,7 +1381,7 @@ static void ttf_reindex_glyphs(void)
         /* scan form `index123' */
         if (sscanf(e->name, GLYPH_PREFIX_INDEX "%i", &index) == 1) {
             if (index >= glyphs_count) {
-                pdftex_warn("`%s' out of valid range [0..%i)",
+                luatex_warn("`%s' out of valid range [0..%i)",
                             e->name, glyphs_count);
                 continue;
             }
@@ -1396,7 +1396,7 @@ static void ttf_reindex_glyphs(void)
                 if (cmap == NULL)
                     cmap = ttf_read_cmap(fd_cur->fm->ff_name, 0, 3, false);
                 if (cmap == NULL) {
-                    pdftex_warn
+                    luatex_warn
                         ("no unicode mapping found, all `uniXXXX' names will be ignored");
                     cmap_not_found = true;      /* once only */
                 }
@@ -1407,7 +1407,7 @@ static void ttf_reindex_glyphs(void)
             assert(t != NULL);
             if (t[index] != -1) {
                 if (t[index] >= glyphs_count) {
-                    pdftex_warn
+                    luatex_warn
                         ("`%s' is mapped to index %li which is out of valid range [0..%i)",
                          e->name, t[index], glyphs_count);
                     continue;
@@ -1415,7 +1415,7 @@ static void ttf_reindex_glyphs(void)
                 glyph = glyph_tab + t[index];
                 goto append_new_glyph;
             } else {
-                pdftex_warn("`unicode %s%.4X' is not mapped to any glyph",
+                luatex_warn("`unicode %s%.4X' is not mapped to any glyph",
                             GLYPH_PREFIX_UNICODE, index);
                 continue;
             }
@@ -1425,7 +1425,7 @@ static void ttf_reindex_glyphs(void)
             if (glyph->name != notdef && strcmp(glyph->name, e->name) == 0)
                 break;
         if (!(glyph - glyph_tab < glyphs_count)) {
-            pdftex_warn("glyph `%s' not found", e->name);
+            luatex_warn("glyph `%s' not found", e->name);
             continue;
         }
       append_new_glyph:
@@ -1556,7 +1556,7 @@ static void ttf_write_OS2(PDF pdf)
     ttf_reset_chksm(pdf, tab);
     version = get_ushort();
     if (version > 3)
-        pdftex_fail("unknown version of OS/2 table (%.4X)", version);
+        luatex_fail("unknown version of OS/2 table (%.4X)", version);
     (void) put_ushort(0x0001);  /* fix version to 1 */
     ttf_ncopy(pdf,
               2 * TTF_USHORT_SIZE + 13 * TTF_SHORT_SIZE + 10 * TTF_BYTE_SIZE);
@@ -1694,7 +1694,7 @@ void writettf(PDF pdf, fd_entry * fd)
 
     if (is_subsetted(fd_cur->fm) && (fd_cur->fe == NULL)
         && !is_subfont(fd_cur->fm)) {
-        pdftex_fail("Subset TrueType must be a reencoded or a subfont");
+        luatex_fail("Subset TrueType must be a reencoded or a subfont");
     }
     ttf_curbyte = 0;
     ttf_size = 0;
@@ -1702,7 +1702,7 @@ void writettf(PDF pdf, fd_entry * fd)
     cur_file_name =
         luatex_find_file(fd_cur->fm->ff_name, find_truetype_file_callback);
     if (cur_file_name == NULL) {
-        pdftex_fail("cannot find TrueType font file for reading (%s)", fd_cur->fm->ff_name);
+        luatex_fail("cannot find TrueType font file for reading (%s)", fd_cur->fm->ff_name);
     }
     callback_id = callback_defined(read_truetype_file_callback);
     if (callback_id > 0) {
@@ -1710,11 +1710,11 @@ void writettf(PDF pdf, fd_entry * fd)
                          &file_opened, &ttf_buffer, &ttf_size) &&
             file_opened && ttf_size > 0) {
         } else {
-            pdftex_fail("cannot open TrueType font file for reading (%s)", cur_file_name);
+            luatex_fail("cannot open TrueType font file for reading (%s)", cur_file_name);
         }
     } else {
         if (!ttf_open(cur_file_name)) {
-            pdftex_fail("cannot open TrueType font file for reading (%s)", cur_file_name);
+            luatex_fail("cannot open TrueType font file for reading (%s)", cur_file_name);
         }
         ttf_read_file();
         ttf_close();
@@ -1807,7 +1807,7 @@ void writeotf(PDF pdf, fd_entry * fd)
     cur_file_name =
         luatex_find_file(fd_cur->fm->ff_name, find_opentype_file_callback);
     if (cur_file_name == NULL) {
-        pdftex_fail("cannot find OpenType font file for reading (%s)", fd_cur->fm->ff_name);
+        luatex_fail("cannot find OpenType font file for reading (%s)", fd_cur->fm->ff_name);
     }
     callback_id = callback_defined(read_opentype_file_callback);
     if (callback_id > 0) {
@@ -1815,11 +1815,11 @@ void writeotf(PDF pdf, fd_entry * fd)
                          &file_opened, &ttf_buffer, &ttf_size) &&
             file_opened && ttf_size > 0) {
         } else {
-            pdftex_fail("cannot open OpenType font file for reading (%s)", cur_file_name);
+            luatex_fail("cannot open OpenType font file for reading (%s)", cur_file_name);
         }
     } else {
         if (!otf_open(cur_file_name)) {
-            pdftex_fail("cannot open OpenType font file for reading (%s)", cur_file_name);
+            luatex_fail("cannot open OpenType font file for reading (%s)", cur_file_name);
         }
         ttf_read_file();
         ttf_close();
diff --git a/source/texk/web2c/luatexdir/font/writetype0.w b/source/texk/web2c/luatexdir/font/writetype0.w
index afa88433626adb6d28747a023add26c70a86f873..c407b1f0069dd567dab3f089f00a8285dbf79cfe 100644
--- a/source/texk/web2c/luatexdir/font/writetype0.w
+++ b/source/texk/web2c/luatexdir/font/writetype0.w
@@ -48,7 +48,7 @@ void writetype0(PDF pdf, fd_entry * fd)
     cur_file_name =
         luatex_find_file(fd_cur->fm->ff_name, find_opentype_file_callback);
     if (cur_file_name == NULL) {
-        pdftex_fail("cannot find OpenType font file for reading (%s)",
+        luatex_fail("cannot find OpenType font file for reading (%s)",
                     fd_cur->fm->ff_name);
     }
     callback_id = callback_defined(read_opentype_file_callback);
@@ -57,12 +57,12 @@ void writetype0(PDF pdf, fd_entry * fd)
                          &file_opened, &ttf_buffer, &ttf_size) &&
             file_opened && ttf_size > 0) {
         } else {
-            pdftex_fail("cannot open OpenType font file for reading (%s)",
+            luatex_fail("cannot open OpenType font file for reading (%s)",
                         cur_file_name);
         }
     } else {
         if (!otf_open(cur_file_name)) {
-            pdftex_fail("cannot open OpenType font file for reading (%s)",
+            luatex_fail("cannot open OpenType font file for reading (%s)",
                         cur_file_name);
         }
         ttf_read_file();
diff --git a/source/texk/web2c/luatexdir/font/writetype2.w b/source/texk/web2c/luatexdir/font/writetype2.w
index e3c0d4af6cac23396ecf883332776b365e1107f4..49765f0ae6391249f284dbcf90c57d8d3ee82dcd 100644
--- a/source/texk/web2c/luatexdir/font/writetype2.w
+++ b/source/texk/web2c/luatexdir/font/writetype2.w
@@ -153,7 +153,7 @@ void writetype2(PDF pdf, fd_entry * fd)
     cur_file_name =
         luatex_find_file(fd_cur->fm->ff_name, find_opentype_file_callback);
     if (cur_file_name == NULL) {
-        pdftex_fail("cannot find OpenType font file for reading (%s)", fd_cur->fm->ff_name);
+        luatex_fail("cannot find OpenType font file for reading (%s)", fd_cur->fm->ff_name);
     }
     callback_id = callback_defined(read_opentype_file_callback);
     if (callback_id > 0) {
@@ -161,11 +161,11 @@ void writetype2(PDF pdf, fd_entry * fd)
                          &file_opened, &ttf_buffer, &ttf_size) &&
             file_opened && ttf_size > 0) {
         } else {
-            pdftex_fail("cannot open OpenType font file for reading (%s)", cur_file_name);
+            luatex_fail("cannot open OpenType font file for reading (%s)", cur_file_name);
         }
     } else {
         if (!otf_open(cur_file_name)) {
-            pdftex_fail("cannot open OpenType font file for reading (%s)", cur_file_name);
+            luatex_fail("cannot open OpenType font file for reading (%s)", cur_file_name);
         }
         ttf_read_file();
         ttf_close();
diff --git a/source/texk/web2c/luatexdir/image/image.h b/source/texk/web2c/luatexdir/image/image.h
index 7c83837c614e6b736104e12a19eb68012a598611..543a968c74e60e52625218b800b95f8efb9d7e68 100644
--- a/source/texk/web2c/luatexdir/image/image.h
+++ b/source/texk/web2c/luatexdir/image/image.h
@@ -35,8 +35,8 @@ extern scaled one_hundred_bp;   /* from pdfgen.w */
 #  define bp2sp(p)        do_zround(p * (one_hundred_bp / 100.0))
 #  define sp2bp(i)        (i * 100.0 / one_hundred_bp)
 
-#  define TYPE_IMG        "image"
-#  define TYPE_IMG_DICT   "image-dict"
+#  define TYPE_IMG        "image.meta"
+#  define TYPE_IMG_DICT   "image.dict"
 
 /**********************************************************************/
 
diff --git a/source/texk/web2c/luatexdir/image/pdftoepdf.w b/source/texk/web2c/luatexdir/image/pdftoepdf.w
index 3618b090eefad0dac43ac49bbabea12267a41c2b..e97a98ea9d0d124ab1b7f35ddfe702b413e2ada3 100644
--- a/source/texk/web2c/luatexdir/image/pdftoepdf.w
+++ b/source/texk/web2c/luatexdir/image/pdftoepdf.w
@@ -70,14 +70,14 @@ static char *get_file_checksum(char *a, file_error_mode fe)
         time_t mtime = finfo.st_mtime;
         ck = (char *) malloc(PDF_CHECKSUM_SIZE);
         if (ck == NULL)
-            pdftex_fail("PDF inclusion: out of memory while processing '%s'",
+            luatex_fail("PDF inclusion: out of memory while processing '%s'",
                         a);
         snprintf(ck, PDF_CHECKSUM_SIZE, "%" PRIu64 "_%" PRIu64, (uint64_t) size,
                  (uint64_t) mtime);
    } else {
         switch (fe) {
         case FE_FAIL:
-            pdftex_fail("PDF inclusion: could not stat() file '%s'", a);
+            luatex_fail("PDF inclusion: could not stat() file '%s'", a);
             break;
         case FE_RETURN_NULL:
             if (ck != NULL)
@@ -127,7 +127,7 @@ PdfDocument *refPdfDocument(char *file_path, file_error_mode fe)
 #endif
         assert(pdf_doc->checksum != NULL);
         if (strncmp(pdf_doc->checksum, checksum, PDF_CHECKSUM_SIZE) != 0) {
-            pdftex_fail("PDF inclusion: file has changed '%s'", file_path);
+            luatex_fail("PDF inclusion: file has changed '%s'", file_path);
         }
         free(checksum);
     }
@@ -144,7 +144,7 @@ PdfDocument *refPdfDocument(char *file_path, file_error_mode fe)
         if (!doc->isOk() || !doc->okToPrint()) {
             switch (fe) {
             case FE_FAIL:
-                pdftex_fail("xpdf: reading PDF image failed");
+                luatex_fail("xpdf: reading PDF image failed");
                 break;
             case FE_RETURN_NULL:
                 delete doc;
@@ -242,7 +242,7 @@ static int addInObj(PDF pdf, PdfDocument * pdf_doc, Ref ref)
     ObjMap *obj_map;
     InObj *p, *q, *n;
     if (ref.num == 0) {
-        pdftex_fail("PDF inclusion: reference to invalid object"
+        luatex_fail("PDF inclusion: reference to invalid object"
                     " (is the included pdf broken?)");
     }
     if ((obj_map = findObjMap(pdf_doc, ref)) != NULL)
@@ -429,7 +429,7 @@ static void copyObject(PDF pdf, PdfDocument * pdf_doc, Object * obj)
     case objError:
     case objEOF:
     case objNone:
-        pdftex_fail("PDF inclusion: type <%s> cannot be copied",
+        luatex_fail("PDF inclusion: type <%s> cannot be copied",
                     obj->getTypeName());
         break;
     default:
@@ -482,7 +482,7 @@ static PDFRectangle *get_pagebox(Page * page, int pagebox_spec)
         return page->getArtBox();
         break;
     default:
-        pdftex_fail("PDF inclusion: unknown value of pagebox spec (%i)",
+        luatex_fail("PDF inclusion: unknown value of pagebox spec (%i)",
                     (int) pagebox_spec);
     }
     return page->getMediaBox(); // to make the compiler happy
@@ -530,10 +530,10 @@ read_pdf_info(image_dict * idict, int minor_pdf_version_wanted,
         const char *msg =
             "PDF inclusion: found PDF version <%d.%d>, but at most version <1.%d> allowed";
         if (pdf_inclusion_errorlevel > 0) {
-            pdftex_fail(msg, pdf_major_version_found, pdf_minor_version_found,
+            luatex_fail(msg, pdf_major_version_found, pdf_minor_version_found,
                         minor_pdf_version_wanted);
         } else {
-            pdftex_warn(msg, pdf_major_version_found, pdf_minor_version_found,
+            luatex_warn(msg, pdf_major_version_found, pdf_minor_version_found,
                         minor_pdf_version_wanted);
         }
     }
@@ -543,19 +543,19 @@ read_pdf_info(image_dict * idict, int minor_pdf_version_wanted,
         GooString name(img_pagename(idict));
         LinkDest *link = doc->findDest(&name);
         if (link == NULL || !link->isOk())
-            pdftex_fail("PDF inclusion: invalid destination <%s>",
+            luatex_fail("PDF inclusion: invalid destination <%s>",
                         img_pagename(idict));
         Ref ref = link->getPageRef();
         img_pagenum(idict) = catalog->findPage(ref.num, ref.gen);
         if (img_pagenum(idict) == 0)
-            pdftex_fail("PDF inclusion: destination is not a page <%s>",
+            luatex_fail("PDF inclusion: destination is not a page <%s>",
                         img_pagename(idict));
         delete link;
     } else {
         // get page by number
         if (img_pagenum(idict) <= 0
             || img_pagenum(idict) > img_totalpages(idict))
-            pdftex_fail("PDF inclusion: required page <%i> does not exist",
+            luatex_fail("PDF inclusion: required page <%i> does not exist",
                         (int) img_pagenum(idict));
     }
     // get the required page
@@ -600,7 +600,7 @@ read_pdf_info(image_dict * idict, int minor_pdf_version_wanted,
         img_rotation(idict) = 1;
         break;
     default:
-        pdftex_warn
+        luatex_warn
             ("PDF inclusion: "
              "/Rotate parameter in PDF file not multiple of 90 degrees.");
     }
@@ -695,7 +695,7 @@ void write_epdf(PDF pdf, image_dict * idict)
     // Metadata validity check (as a stream it must be indirect)
     pageDict->lookupNF((char *) "Metadata", &obj1);
     if (!obj1.isNull() && !obj1.isRef())
-        pdftex_warn("PDF inclusion: /Metadata must be indirect object");
+        luatex_warn("PDF inclusion: /Metadata must be indirect object");
     obj1.free();
 
     // copy selected items in Page dictionary
@@ -732,7 +732,7 @@ void write_epdf(PDF pdf, image_dict * idict)
             op2->free();
         };
         if (!op1->isDict())
-            pdftex_warn("PDF inclusion: Page /Resources missing.");
+            luatex_warn("PDF inclusion: Page /Resources missing.");
         op1->free();
     }
     obj1.free();
@@ -751,7 +751,7 @@ void write_epdf(PDF pdf, image_dict * idict)
         //
         contents.streamGetDict()->lookup((char *) "F", &obj1);
         if (!obj1.isNull()) {
-            pdftex_fail("PDF inclusion: Unsupported external stream");
+            luatex_fail("PDF inclusion: Unsupported external stream");
         }
         obj1.free();
         contents.streamGetDict()->lookup((char *) "Length", &obj1);
diff --git a/source/texk/web2c/luatexdir/image/writeimg.w b/source/texk/web2c/luatexdir/image/writeimg.w
index d5d533821180ad8982657fafcf0444c6f7b5c5eb..bb47b05c6001936595dff82feecfdb39dc081bae 100644
--- a/source/texk/web2c/luatexdir/image/writeimg.w
+++ b/source/texk/web2c/luatexdir/image/writeimg.w
@@ -141,7 +141,7 @@ static void check_type_by_header(image_dict * idict)
     for (i = 0; (unsigned) i < MAX_HEADER; i++) {
         header[i] = (char) xgetc(file);
         if (feof(file))
-            pdftex_fail("reading image file failed");
+            luatex_fail("reading image file failed");
     }
     xfclose(file, img_filepath(idict));
     /* tests */
@@ -292,7 +292,7 @@ void read_img(PDF pdf,
     int callback_id;
     assert(idict != NULL);
     if (img_filename(idict) == NULL)
-        pdftex_fail("image file name missing");
+        luatex_fail("image file name missing");
     callback_id = callback_defined(find_image_file_callback);
     if (img_filepath(idict) == NULL) {
         if (callback_id > 0
@@ -304,7 +304,7 @@ void read_img(PDF pdf,
             img_filepath(idict) =
                 kpse_find_file(img_filename(idict), kpse_tex_format, true);
         if (img_filepath(idict) == NULL)
-            pdftex_fail("cannot find image file '%s'", img_filename(idict));
+            luatex_fail("cannot find image file '%s'", img_filename(idict));
     }
     recorder_record_input(img_filename(idict));
     /* type checks */
@@ -328,14 +328,14 @@ void read_img(PDF pdf,
         break;
     case IMG_TYPE_JBIG2:
         if (minor_version < 4) {
-            pdftex_fail
+            luatex_fail
                 ("JBIG2 images only possible with at least PDF 1.4; you are generating PDF 1.%i",
                  (int) minor_version);
         }
         read_jbig2_info(idict);
         break;
     default:
-        pdftex_fail("internal error: unknown image type (2)");
+        luatex_fail("internal error: unknown image type (2)");
     }
     cur_file_name = NULL;
     if (img_state(idict) < DICT_FILESCANNED)
@@ -538,11 +538,11 @@ scaled_whd scale_img(image_dict * idict, scaled_whd alt_rule, int transform)
     xr = img_xres(idict);
     yr = img_yres(idict);
     if (x <= 0 || y <= 0 || xr < 0 || yr < 0)
-        pdftex_fail("ext1: invalid image dimensions");
+        luatex_fail("ext1: invalid image dimensions");
     if (xr > 65535 || yr > 65535) {
         xr = 0;
         yr = 0;
-        pdftex_warn("ext1: too large image resolution ignored");
+        luatex_warn("ext1: too large image resolution ignored");
     }
     if (((transform - img_rotation(idict)) & 1) == 1) {
         tmp = x;
@@ -601,7 +601,7 @@ void write_img(PDF pdf, image_dict * idict)
             write_pdfstream(pdf, idict);
             break;
         default:
-            pdftex_fail("internal error: unknown image type (1)");
+            luatex_fail("internal error: unknown image type (1)");
         }
         if (tracefilenames)
             tex_printf(">");
@@ -625,7 +625,7 @@ void pdf_write_image(PDF pdf, int n)
 void check_pdfstream_dict(image_dict * idict)
 {
     if (!img_is_bbox(idict))
-        pdftex_fail("image.stream: no bbox given");
+        luatex_fail("image.stream: no bbox given");
     if (img_state(idict) < DICT_FILESCANNED)
         img_state(idict) = DICT_FILESCANNED;
 }
@@ -822,14 +822,14 @@ void undumpimagemeta(PDF pdf, int pdfversion, int pdfinclusionerrorlevel)
             break;
         case IMG_TYPE_JBIG2:
             if (pdfversion < 4) {
-                pdftex_fail
+                luatex_fail
                     ("JBIG2 images only possible with at least PDF 1.4; you are generating PDF 1.%i",
                      (int) pdfversion);
             }
             undumpinteger(img_pagenum(idict));
             break;
         default:
-            pdftex_fail("unknown type of image");
+            luatex_fail("unknown type of image");
         }
         read_img(pdf, idict, pdfversion, pdfinclusionerrorlevel);
     }
diff --git a/source/texk/web2c/luatexdir/image/writejbig2.w b/source/texk/web2c/luatexdir/image/writejbig2.w
index daf12df58c2f8da62cffe5088ff60c0a55a23a9b..910dc0a2af056aacd7c79ef7e9d101950255ef9b 100644
--- a/source/texk/web2c/luatexdir/image/writejbig2.w
+++ b/source/texk/web2c/luatexdir/image/writejbig2.w
@@ -209,9 +209,9 @@ static int ygetc(FILE * stream)
     int c = getc(stream);
     if (c < 0) {
         if (c == EOF)
-            pdftex_fail("getc() failed; premature end of JBIG2 image file");
+            luatex_fail("getc() failed; premature end of JBIG2 image file");
         else
-            pdftex_fail("getc() failed (can't happen)");
+            luatex_fail("getc() failed (can't happen)");
     }
     return c;
 }
@@ -384,7 +384,7 @@ static void readfilehdr(FILEINFO * fip)
     xfseek(fip->file, 0, SEEK_SET, fip->filepath);
     for (i = 0; i < 8; i++)
         if (ygetc(fip->file) != jbig2_id[i])
-            pdftex_fail
+            luatex_fail
                 ("readfilehdr(): reading JBIG2 image file failed: ID string missing");
     /* Annex D.4.2 File header flags */
     fip->filehdrflags = (unsigned int) ygetc(fip->file);
@@ -441,7 +441,7 @@ static void checkseghdrflags(SEGINFO * sip)
     case M_Extension:
         break;
     default:
-        pdftex_fail
+        luatex_fail
             ("checkseghdrflags(): unknown segment type in JBIG2 image file");
         break;
     }
@@ -790,7 +790,7 @@ void read_jbig2_info(image_dict * idict)
     assert(idict != NULL);
     img_type(idict) = IMG_TYPE_JBIG2;
     if (img_pagenum(idict) < 1)
-        pdftex_fail
+        luatex_fail
             ("read_jbig2_info(): page %d not in JBIG2 image file; page must be > 0",
              (int) img_pagenum(idict));
     if (file_tree == NULL) {
@@ -816,7 +816,7 @@ void read_jbig2_info(image_dict * idict)
     }
     pip = find_pageinfo(&(fip->pages), (unsigned long) img_pagenum(idict));
     if (pip == NULL)
-        pdftex_fail("read_jbig2_info(): page %d not found in JBIG2 image file",
+        luatex_fail("read_jbig2_info(): page %d not found in JBIG2 image file",
                     (int) img_pagenum(idict));
     img_totalpages(idict) = (int) fip->numofpages;
     img_xsize(idict) = (int) pip->width;
diff --git a/source/texk/web2c/luatexdir/image/writejp2.w b/source/texk/web2c/luatexdir/image/writejp2.w
index e4f2b721bdf0f5d11a4d36bcbf54b1307379ff6f..db90f40ddd679971a5c42172e3377f86861f01fe 100644
--- a/source/texk/web2c/luatexdir/image/writejp2.w
+++ b/source/texk/web2c/luatexdir/image/writejp2.w
@@ -69,7 +69,7 @@ static hdr_struct read_boxhdr(image_dict * idict)
     if (hdr.lbox == 1)
         hdr.lbox = read8bytes(img_file(idict));
     if (hdr.lbox == 0 && hdr.tbox != BOX_JP2C)
-        pdftex_fail("reading JP2 image failed (LBox == 0)");
+        luatex_fail("reading JP2 image failed (LBox == 0)");
     return hdr;
 }
 
@@ -125,20 +125,20 @@ static void scan_res(image_dict * idict, uint64_t epos_s)
             if (img_xres(idict) == 0 && img_yres(idict) == 0) {
                 scan_resc_resd(idict);
                 if (xftell(img_file(idict), img_filepath(idict)) != (long)epos)
-                    pdftex_fail
+                    luatex_fail
                         ("reading JP2 image failed (resc box size inconsistent)");
             }
             break;
         case (BOX_RESD):
             scan_resc_resd(idict);
             if (xftell(img_file(idict), img_filepath(idict)) != (long)epos)
-                pdftex_fail
+                luatex_fail
                     ("reading JP2 image failed (resd box size inconsistent)");
             break;
         default:;
         }
         if (epos > epos_s)
-            pdftex_fail("reading JP2 image failed (res box size inconsistent)");
+            luatex_fail("reading JP2 image failed (res box size inconsistent)");
         if (epos == epos_s)
             break;
         xfseek(img_file(idict), (long) epos, SEEK_SET, img_filepath(idict));
@@ -160,7 +160,7 @@ static boolean scan_jp2h(image_dict * idict, uint64_t epos_s)
         case (BOX_IHDR):
             scan_ihdr(idict);
             if (xftell(img_file(idict), img_filepath(idict)) != (long)epos)
-                pdftex_fail
+                luatex_fail
                     ("reading JP2 image failed (ihdr box size inconsistent)");
             ihdr_found = true;
             break;
@@ -170,7 +170,7 @@ static boolean scan_jp2h(image_dict * idict, uint64_t epos_s)
         default:;
         }
         if (epos > epos_s)
-            pdftex_fail
+            luatex_fail
                 ("reading JP2 image failed (jp2h box size inconsistent)");
         if (epos == epos_s)
             break;
@@ -221,7 +221,7 @@ void read_jp2_info(image_dict * idict, img_readtype_e readtype)
     spos = epos;
     hdr = read_boxhdr(idict);
     if (hdr.tbox != BOX_FTYP)
-        pdftex_fail("reading JP2 image failed (missing ftyp box)");
+        luatex_fail("reading JP2 image failed (missing ftyp box)");
     epos = spos + hdr.lbox;
     xfseek(img_file(idict), (long) epos, SEEK_SET, img_filepath(idict));
 
@@ -235,7 +235,7 @@ void read_jp2_info(image_dict * idict, img_readtype_e readtype)
             break;
         case BOX_JP2C:
             if (!ihdr_found)
-                pdftex_fail("reading JP2 image failed (no ihdr box found)");
+                luatex_fail("reading JP2 image failed (no ihdr box found)");
             break;
         default:;
         }
@@ -255,7 +255,7 @@ static void reopen_jp2(image_dict * idict)
     read_jp2_info(idict, IMG_KEEPOPEN);
     if (width != img_xsize(idict) || height != img_ysize(idict)
         || xres != img_xres(idict) || yres != img_yres(idict))
-        pdftex_fail("writejp2: image dimensions have changed");
+        luatex_fail("writejp2: image dimensions have changed");
 }
 
 void write_jp2(PDF pdf, image_dict * idict)
@@ -281,7 +281,7 @@ void write_jp2(PDF pdf, image_dict * idict)
     l = (long unsigned int) img_jp2_ptr(idict)->length;
     xfseek(img_file(idict), 0, SEEK_SET, img_filepath(idict));
     if (read_file_to_buf(pdf, img_file(idict), l) != l)
-        pdftex_fail("writejp2: fread failed");
+        luatex_fail("writejp2: fread failed");
     pdf_end_stream(pdf);
     pdf_end_obj(pdf);
     close_and_cleanup_jp2(idict);
diff --git a/source/texk/web2c/luatexdir/image/writejpg.w b/source/texk/web2c/luatexdir/image/writejpg.w
index d9e0b0a6ec8c784fd405506b68c650efca53cd4c..8ad6d656ebfb5db3b6af71da5e09351842f6d248 100644
--- a/source/texk/web2c/luatexdir/image/writejpg.w
+++ b/source/texk/web2c/luatexdir/image/writejpg.w
@@ -130,7 +130,7 @@ void read_jpg_info(PDF pdf, image_dict * idict, img_readtype_e readtype)
     img_jpg_ptr(idict)->length = xftell(img_file(idict), img_filepath(idict));
     xfseek(img_file(idict), 0, SEEK_SET, img_filepath(idict));
     if ((unsigned int) read2bytes(img_file(idict)) != 0xFFD8)
-        pdftex_fail("reading JPEG image failed (no JPEG header found)");
+        luatex_fail("reading JPEG image failed (no JPEG header found)");
     /* currently only true JFIF files allow extracting |img_xres| and |img_yres| */
     if ((unsigned int) read2bytes(img_file(idict)) == 0xFFE0) { /* check for JFIF */
         (void) read2bytes(img_file(idict));
@@ -166,9 +166,9 @@ void read_jpg_info(PDF pdf, image_dict * idict, img_readtype_e readtype)
     xfseek(img_file(idict), 0, SEEK_SET, img_filepath(idict));
     while (1) {
         if (feof(img_file(idict)))
-            pdftex_fail("reading JPEG image failed (premature file end)");
+            luatex_fail("reading JPEG image failed (premature file end)");
         if (fgetc(img_file(idict)) != 0xFF)
-            pdftex_fail("reading JPEG image failed (no marker found)");
+            luatex_fail("reading JPEG image failed (no marker found)");
         i = xgetc(img_file(idict));
         switch (i) {
         case M_SOF3:           /* lossless */
@@ -181,11 +181,11 @@ void read_jpg_info(PDF pdf, image_dict * idict, img_readtype_e readtype)
         case M_SOF13:
         case M_SOF14:
         case M_SOF15:          /* lossless */
-            pdftex_fail("unsupported type of compression (SOF_%d)", i - M_SOF0);
+            luatex_fail("unsupported type of compression (SOF_%d)", i - M_SOF0);
             break;
         case M_SOF2:
             if (pdf->minor_version <= 2)
-                pdftex_fail("cannot use progressive DCT with PDF-1.2");
+                luatex_fail("cannot use progressive DCT with PDF-1.2");
         case M_SOF0:
         case M_SOF1:
             (void) read2bytes(img_file(idict)); /* read segment length  */
@@ -205,7 +205,7 @@ void read_jpg_info(PDF pdf, image_dict * idict, img_readtype_e readtype)
                 img_procset(idict) |= PROCSET_IMAGE_C;
                 break;
             default:
-                pdftex_fail("Unsupported color space %i",
+                luatex_fail("Unsupported color space %i",
                             (int) img_jpg_color(idict));
             }
             if (readtype == IMG_CLOSEINBETWEEN)
@@ -243,7 +243,7 @@ static void reopen_jpg(PDF pdf, image_dict * idict)
     read_jpg_info(pdf, idict, IMG_KEEPOPEN);
     if (width != img_xsize(idict) || height != img_ysize(idict)
         || xres != img_xres(idict) || yres != img_yres(idict))
-        pdftex_fail("writejpg: image dimensions have changed");
+        luatex_fail("writejpg: image dimensions have changed");
 }
 
 @ @c
@@ -290,7 +290,7 @@ void write_jpg(PDF pdf, image_dict * idict)
             pdf_end_array(pdf);
             break;
         default:
-            pdftex_fail("Unsupported color space %i",
+            luatex_fail("Unsupported color space %i",
                         (int) img_jpg_color(idict));
         }
     }
@@ -301,7 +301,7 @@ void write_jpg(PDF pdf, image_dict * idict)
     l = (size_t) img_jpg_ptr(idict)->length;
     xfseek(img_file(idict), 0, SEEK_SET, img_filepath(idict));
     if (read_file_to_buf(pdf, img_file(idict), l) != l)
-        pdftex_fail("writejpg: fread failed");
+        luatex_fail("writejpg: fread failed");
     pdf_end_stream(pdf);
     pdf_end_obj(pdf);
     close_and_cleanup_jpg(idict);
diff --git a/source/texk/web2c/luatexdir/image/writepng.w b/source/texk/web2c/luatexdir/image/writepng.w
index 8b0de731b409db2a456f1f8f7b8bd084efbc029e..d6744c76a1abf44686703d40a407b1d3442a5753 100644
--- a/source/texk/web2c/luatexdir/image/writepng.w
+++ b/source/texk/web2c/luatexdir/image/writepng.w
@@ -60,13 +60,13 @@ void read_png_info(image_dict * idict, img_readtype_e readtype)
     img_png_ptr(idict) = xtalloc(1, png_img_struct);
     if ((png_p = png_create_read_struct(PNG_LIBPNG_VER_STRING,
                                         NULL, NULL, NULL)) == NULL)
-        pdftex_fail("libpng: png_create_read_struct() failed");
+        luatex_fail("libpng: png_create_read_struct() failed");
     img_png_png_ptr(idict) = png_p;
     if ((info_p = png_create_info_struct(png_p)) == NULL)
-        pdftex_fail("libpng: png_create_info_struct() failed");
+        luatex_fail("libpng: png_create_info_struct() failed");
     img_png_info_ptr(idict) = info_p;
     if (setjmp(png_jmpbuf(png_p)))
-        pdftex_fail("libpng: internal error");
+        luatex_fail("libpng: internal error");
 #if PNG_LIBPNG_VER >= 10603
     /* ignore possibly incorrect CMF bytes */
     png_set_option(png_p, PNG_MAXIMUM_INFLATE_WINDOW, PNG_OPTION_ON);
@@ -95,7 +95,7 @@ void read_png_info(image_dict * idict, img_readtype_e readtype)
         img_procset(idict) |= PROCSET_IMAGE_C;
         break;
     default:
-        pdftex_fail("unsupported type of color_type <%i>",
+        luatex_fail("unsupported type of color_type <%i>",
                     (int) png_get_color_type(png_p, info_p));
     }
     img_colordepth(idict) = png_get_bit_depth(png_p, info_p);
@@ -234,7 +234,7 @@ static void write_png_gray(PDF pdf, image_dict * idict)
     } else {
         if (png_get_image_height(png_p, info_p) *
             png_get_rowbytes(png_p, info_p) >= 10240000L)
-            pdftex_warn
+            luatex_warn
                 ("large interlaced PNG might cause out of memory (use non-interlaced PNG to fix this)");
         rows = xtalloc(png_get_image_height(png_p, info_p), png_bytep);
         for (i = 0; i < (int) png_get_image_height(png_p, info_p); i++)
@@ -280,7 +280,7 @@ static void write_png_gray_alpha(PDF pdf, image_dict * idict)
     } else {
         if (png_get_image_height(png_p, info_p) *
             png_get_rowbytes(png_p, info_p) >= 10240000L)
-            pdftex_warn
+            luatex_warn
                 ("large interlaced PNG might cause out of memory (use non-interlaced PNG to fix this)");
         rows = xtalloc(png_get_image_height(png_p, info_p), png_bytep);
         for (i = 0; i < (int) png_get_image_height(png_p, info_p); i++)
@@ -333,7 +333,7 @@ static void write_png_rgb_alpha(PDF pdf, image_dict * idict)
     } else {
         if (png_get_image_height(png_p, info_p) *
             png_get_rowbytes(png_p, info_p) >= 10240000L)
-            pdftex_warn
+            luatex_warn
                 ("large interlaced PNG might cause out of memory (use non-interlaced PNG to fix this)");
         rows = xtalloc(png_get_image_height(png_p, info_p), png_bytep);
         for (i = 0; i < (int) png_get_image_height(png_p, info_p); i++)
@@ -371,7 +371,7 @@ static int spng_getint(FILE * f)
 {
     unsigned char buf[4];
     if (fread(buf, 1, 4, f) != 4)
-        pdftex_fail("writepng: reading chunk type failed");
+        luatex_fail("writepng: reading chunk type failed");
     return ((((((int) buf[0] << 8) + buf[1]) << 8) + buf[2]) << 8) + buf[3];
 }
 
@@ -392,7 +392,7 @@ static void copy_png(PDF pdf, image_dict * idict)
     f = (FILE *) png_get_io_ptr(png_p);
     /* 1st pass to find overall stream /Length */
     if (fseek(f, 8, SEEK_SET) != 0)
-        pdftex_fail("writepng: fseek in PNG file failed (1)");
+        luatex_fail("writepng: fseek in PNG file failed (1)");
     do {
         len = spng_getint(f);
         type = spng_getint(f);
@@ -404,7 +404,7 @@ static void copy_png(PDF pdf, image_dict * idict)
             streamlength += len;
         default:
             if (fseek(f, len + 4, SEEK_CUR) != 0)
-                pdftex_fail("writepng: fseek in PNG file failed (2)");
+                luatex_fail("writepng: fseek in PNG file failed (2)");
         }
     } while (endflag == false);
     pdf_dict_add_int(pdf, "Length", streamlength);
@@ -424,19 +424,19 @@ static void copy_png(PDF pdf, image_dict * idict)
     /* 2nd pass to copy data */
     endflag = false;
     if (fseek(f, 8, SEEK_SET) != 0)
-        pdftex_fail("writepng: fseek in PNG file failed (3)");
+        luatex_fail("writepng: fseek in PNG file failed (3)");
     do {
         len = spng_getint(f);
         type = spng_getint(f);
         switch (type) {
         case SPNG_CHUNK_IDAT:  /* do copy */
             if (idat == 2)
-                pdftex_fail("writepng: IDAT chunk sequence broken");
+                luatex_fail("writepng: IDAT chunk sequence broken");
             idat = 1;
             if (read_file_to_buf(pdf, f, len) != len)
-                pdftex_fail("writepng: fread failed");
+                luatex_fail("writepng: fread failed");
             if (fseek(f, 4, SEEK_CUR) != 0)
-                pdftex_fail("writepng: fseek in PNG file failed (4)");
+                luatex_fail("writepng: fseek in PNG file failed (4)");
             break;
         case SPNG_CHUNK_IEND:  /* done */
             endflag = true;
@@ -445,7 +445,7 @@ static void copy_png(PDF pdf, image_dict * idict)
             if (idat == 1)
                 idat = 2;
             if (fseek(f, len + 4, SEEK_CUR) != 0)
-                pdftex_fail("writepng: fseek in PNG file failed (5)");
+                luatex_fail("writepng: fseek in PNG file failed (5)");
         }
     } while (endflag == false);
     pdf_end_stream(pdf);
@@ -463,7 +463,7 @@ static void reopen_png(image_dict * idict)
     read_png_info(idict, IMG_KEEPOPEN);
     if (width != img_xsize(idict) || height != img_ysize(idict)
         || xres != img_xres(idict) || yres != img_yres(idict))
-        pdftex_fail("writepng: image dimensions have changed");
+        luatex_fail("writepng: image dimensions have changed");
 }
 
 @ @c
@@ -559,7 +559,7 @@ void write_png(PDF pdf, image_dict * idict)
             pdf_dict_add_name(pdf, "ColorSpace", "DeviceRGB");
             break;
         default:
-            pdftex_fail("unsupported type of color_type <%i>",
+            luatex_fail("unsupported type of color_type <%i>",
                         png_get_color_type(png_p, info_p));
         }
     }
diff --git a/source/texk/web2c/luatexdir/lua/lauxlib_bridge.h b/source/texk/web2c/luatexdir/lua/lauxlib_bridge.h
index 057b5ee9605a3e599c25899fa07795bc7cf5b42f..eec88e976c9add97eabb071e9a0ada0c2185171d 100644
--- a/source/texk/web2c/luatexdir/lua/lauxlib_bridge.h
+++ b/source/texk/web2c/luatexdir/lua/lauxlib_bridge.h
@@ -44,5 +44,18 @@ LUA_API int lua_compare (lua_State *L, int index1, int index2, int op);
 
 #define luaL_newlib(L,l)        (luaL_newlibtable(L,l), luaL_setfuncs(L,l,0))
 
-
+/*  Is this ok as replacement for lua_copy of lua 5.2.3 ? */
+/*
+#if defined(LUAJIT)
+LUA_API void lua_copy (lua_State *L, int fromidx, int toidx) {
+  TValue *fr, *to;
+  lua_lock(L);
+  fr = index2adr(L, fromidx);
+  to = index2adr(L, toidx);
+  api_checkvalidindex(L, to);
+  copyTV(L,to,fr);
+  lua_unlock(L);
+}
+#endif
+*/
 #endif
diff --git a/source/texk/web2c/luatexdir/lua/lepdflib.cc b/source/texk/web2c/luatexdir/lua/lepdflib.cc
index b3a86d1a85408063b9a65ce7f51645c3f0dc45fe..a60fdbef03a249c0f8ed0921d8013559ee260f1b 100644
--- a/source/texk/web2c/luatexdir/lua/lepdflib.cc
+++ b/source/texk/web2c/luatexdir/lua/lepdflib.cc
@@ -48,26 +48,26 @@ static const char *ErrorCodeNames[] = { "None", "OpenFile", "BadCatalog",
 
 //**********************************************************************
 
-#define M_Annot            "Annot"
-#define M_Annots           "Annots"
-#define M_Array            "Array"
-#define M_Catalog          "Catalog"
-#define M_Dict             "Dict"
-#define M_EmbFile          "EmbFile"
-#define M_FileSpec         "FileSpec"
-#define M_GooString        "GooString"
-#define M_LinkDest         "LinkDest"
-#define M_Link             "Link"
-#define M_Links            "Links"
-#define M_Object           "Object"
-#define M_Page             "Page"
-#define M_PDFDoc           "PDFDoc"
-#define M_PDFRectangle     "PDFRectangle"
-#define M_Ref              "Ref"
-#define M_Stream           "Stream"
-#define M_StructTreeRoot   "StructTreeRoot"
-#define M_XRefEntry        "XRefEntry"
-#define M_XRef             "XRef"
+#define M_Annot            "epdf.Annot" /* ls-hh: epdf.* gives better protection in registry */
+#define M_Annots           "epdf.Annots"
+#define M_Array            "epdf.Array"
+#define M_Catalog          "epdf.Catalog"
+#define M_Dict             "epdf.Dict"
+#define M_EmbFile          "epdf.EmbFile"
+#define M_FileSpec         "epdf.FileSpec"
+#define M_GooString        "epdf.GooString"
+#define M_LinkDest         "epdf.LinkDest"
+#define M_Link             "epdf.Link"
+#define M_Links            "epdf.Links"
+#define M_Object           "epdf.Object"
+#define M_Page             "epdf.Page"
+#define M_PDFDoc           "epdf.PDFDoc"
+#define M_PDFRectangle     "epdf.PDFRectangle"
+#define M_Ref              "epdf.Ref"
+#define M_Stream           "epdf.Stream"
+#define M_StructTreeRoot   "epdf.StructTreeRoot"
+#define M_XRefEntry        "epdf.XRefEntry"
+#define M_XRef             "epdf.XRef"
 
 //**********************************************************************
 
diff --git a/source/texk/web2c/luatexdir/lua/lfontlib.c b/source/texk/web2c/luatexdir/lua/lfontlib.c
index 5efc1180374c9ab43a874d98c46727d4989acb8b..e9193dca5987ae446e8df9e1a3f96c7d9c101e56 100644
--- a/source/texk/web2c/luatexdir/lua/lfontlib.c
+++ b/source/texk/web2c/luatexdir/lua/lfontlib.c
@@ -283,7 +283,7 @@ static const struct luaL_Reg fontlib[] = {
 int luaopen_font(lua_State * L)
 {
     luaL_register(L, "font", fontlib);
-    make_table(L, "fonts", "getfont", "setfont");
+    make_table(L, "fonts", "tex.fonts", "getfont", "setfont");
     return 1;
 }
 
diff --git a/source/texk/web2c/luatexdir/lua/limglib.c b/source/texk/web2c/luatexdir/lua/limglib.c
index 83a5cdf1ba22b9938f8312be4be5aee6b605c42d..9af57b2679fa215e84d23946bedcf01d1a8b9588 100644
--- a/source/texk/web2c/luatexdir/lua/limglib.c
+++ b/source/texk/web2c/luatexdir/lua/limglib.c
@@ -29,7 +29,7 @@ static const char _svn_version[] =
 #include "lua.h"
 #include "lauxlib.h"
 
-#define IMG_ENV "img_env"
+#define IMG_ENV "image.env"
 
 /**********************************************************************/
 
diff --git a/source/texk/web2c/luatexdir/lua/lkpselib.c b/source/texk/web2c/luatexdir/lua/lkpselib.c
index 9812689ec4df669102fea91127d98f24039ec004..d6c628b53b5e42fddb41521da350ed50c944e9cc 100644
--- a/source/texk/web2c/luatexdir/lua/lkpselib.c
+++ b/source/texk/web2c/luatexdir/lua/lkpselib.c
@@ -153,7 +153,7 @@ static const char *const filetypenames[] = {
 };
 
 
-#define KPATHSEA_METATABLE  "luatex_kpathsea"
+#define KPATHSEA_METATABLE  "luatex.kpathsea"
 
 /* set to 1 by the |program_name| function */
 
diff --git a/source/texk/web2c/luatexdir/lua/llualib.c b/source/texk/web2c/luatexdir/lua/llualib.c
index f0259a453affa3b07928197d52c77e25f7522c7f..244172bd8bae83be7bebcdeb0242e2ec25caf2ef 100644
--- a/source/texk/web2c/luatexdir/lua/llualib.c
+++ b/source/texk/web2c/luatexdir/lua/llualib.c
@@ -128,7 +128,7 @@ void undump_luac_registers(void)
 static void bytecode_register_shadow_set(lua_State * L, int k)
 {
     /* the stack holds the value to be set */
-    lua_pushstring(L, "bytecode_shadow");       /* lua.bytecode_shadow */
+    lua_pushstring(L, "lua.bytecode_shadow");       /* lua.bytecode_shadow */
     lua_rawget(L, LUA_REGISTRYINDEX);
     if (lua_istable(L, -1)) {
         lua_pushvalue(L, -2);
@@ -143,7 +143,7 @@ static int bytecode_register_shadow_get(lua_State * L, int k)
 {
     /* the stack holds the value to be set */
     int ret = 0;
-    lua_pushstring(L, "bytecode_shadow");
+    lua_pushstring(L, "lua.bytecode_shadow");
     lua_rawget(L, LUA_REGISTRYINDEX);
     if (lua_istable(L, -1)) {
         lua_rawgeti(L, -1, k);
@@ -321,10 +321,10 @@ static const struct luaL_Reg lualib[] = {
 int luaopen_lua(lua_State * L, char *fname)
 {
     luaL_register(L, "lua", lualib);
-    make_table(L, "bytecode", "getbytecode", "setbytecode");
-    make_table(L, "name", "getluaname", "setluaname");
+    make_table(L, "bytecode", "tex.bytecode", "getbytecode", "setbytecode");
+    make_table(L, "name",     "tex.name", "getluaname", "setluaname");
     lua_newtable(L);
-    lua_setfield(L, LUA_REGISTRYINDEX, "bytecode_shadow");
+    lua_setfield(L, LUA_REGISTRYINDEX, "lua.bytecode_shadow");
     lua_pushstring(L, LUA_VERSION);
     lua_setfield(L, -2, "version");
     if (fname == NULL) {
diff --git a/source/texk/web2c/luatexdir/lua/lnodelib.c b/source/texk/web2c/luatexdir/lua/lnodelib.c
index 8ffa162e2f6191522518adba67796885259c8ce1..0607dfb5cfce7869166fbf094bc4fe218d0b2829 100644
--- a/source/texk/web2c/luatexdir/lua/lnodelib.c
+++ b/source/texk/web2c/luatexdir/lua/lnodelib.c
@@ -101,6 +101,7 @@ static const char _svn_version[] =
 
 #include "ptexlib.h"
 #include "lua/luatex-api.h"
+#include "lua/lauxlib_bridge.h"
 
 /*
 
@@ -109,25 +110,6 @@ static const char _svn_version[] =
 
 */
 
-#define init_luaS_index(a) do {                        \
-    lua_pushliteral(L,#a);                             \
-    luaS_##a##_ptr = lua_tostring(L,-1);               \
-    luaS_##a##_index = luaL_ref (L,LUA_REGISTRYINDEX); \
-} while (0)
-
-#define init_luaS_index_s(a,b) do {                    \
-    lua_pushliteral(L,b);                              \
-    luaS_##a##_ptr = lua_tostring(L,-1);               \
-    luaS_##a##_index = luaL_ref (L,LUA_REGISTRYINDEX); \
-} while (0)
-
-#define make_luaS_index(a)                    \
-    static int luaS_##a##_index = 0;          \
-    static const char * luaS_##a##_ptr = NULL
-
-#define luaS_index(a) luaS_##a##_index
-
-#define luaS_ptr_eq(a,b) (a==luaS_##b##_ptr)
 
 /*
 
@@ -275,273 +257,11 @@ while (vlink(t)!=current && t != null) { \
         luaL_error(L, "incorrect index value %d for tex.%s()", (int)j, s); \
     }
 
-#define NODE_METATABLE  "luatex_node"
+#define NODE_METATABLE  "luatex.node"
 
 #define DEBUG 0
 #define DEBUG_OUT stdout
 
-make_luaS_index(luatex_node);
-
-make_luaS_index(accent);
-make_luaS_index(action);
-make_luaS_index(action_id);
-make_luaS_index(action_type);
-make_luaS_index(area);
-make_luaS_index(attr);
-make_luaS_index(best_ins_ptr);
-make_luaS_index(bot_accent);
-make_luaS_index(box_left);
-make_luaS_index(box_left_width);
-make_luaS_index(box_right);
-make_luaS_index(box_right_width);
-make_luaS_index(broken_ins);
-make_luaS_index(broken_ptr);
-make_luaS_index(char);
-make_luaS_index(class);
-make_luaS_index(command);
-make_luaS_index(components);
-make_luaS_index(cost);
-make_luaS_index(count);
-make_luaS_index(data);
-make_luaS_index(degree);
-make_luaS_index(delim);
-make_luaS_index(denom);
-make_luaS_index(depth);
-make_luaS_index(dest_id);
-make_luaS_index(dest_type);
-make_luaS_index(dir);
-make_luaS_index(dir_h);
-make_luaS_index(display);
-make_luaS_index(dvi_ptr);
-make_luaS_index(expansion_factor);
-make_luaS_index(ext);
-make_luaS_index(fam);
-make_luaS_index(fast);
-make_luaS_index(file);
-make_luaS_index(font);
-make_luaS_index(global);
-make_luaS_index(glue_order);
-make_luaS_index(glue_set);
-make_luaS_index(glue_sign);
-make_luaS_index(glyph);
-make_luaS_index(head);
-make_luaS_index(height);
-make_luaS_index(id);
-make_luaS_index(index);
-make_luaS_index(kern);
-make_luaS_index(lang);
-make_luaS_index(large_char);
-make_luaS_index(large_fam);
-make_luaS_index(last_ins_ptr);
-make_luaS_index(leader);
-make_luaS_index(left);
-make_luaS_index(level);
-make_luaS_index(link_attr);
-make_luaS_index(list);
-make_luaS_index(mark);
-make_luaS_index(mode);
-make_luaS_index(name);
-make_luaS_index(named_id);
-make_luaS_index(new_window);
-make_luaS_index(next);
-make_luaS_index(nucleus);
-make_luaS_index(num);
-make_luaS_index(number);
-make_luaS_index(objnum);
-make_luaS_index(pen_broken);
-make_luaS_index(pen_inter);
-make_luaS_index(penalty);
-make_luaS_index(post);
-make_luaS_index(pre);
-make_luaS_index(prev);
-make_luaS_index(ref_count);
-make_luaS_index(reg);
-make_luaS_index(replace);
-make_luaS_index(right);
-make_luaS_index(script);
-make_luaS_index(scriptscript);
-make_luaS_index(shift);
-make_luaS_index(shrink);
-make_luaS_index(shrink_order);
-make_luaS_index(small_char);
-make_luaS_index(small_fam);
-make_luaS_index(spec);
-make_luaS_index(stack);
-make_luaS_index(stream);
-make_luaS_index(stretch);
-make_luaS_index(stretch_order);
-make_luaS_index(string);
-make_luaS_index(style);
-make_luaS_index(sub);
-make_luaS_index(subtype);
-make_luaS_index(sup);
-make_luaS_index(surround);
-make_luaS_index(text);
-make_luaS_index(thread_attr);
-make_luaS_index(thread_id);
-make_luaS_index(transform);
-make_luaS_index(type);
-make_luaS_index(uchyph);
-make_luaS_index(user_id);
-make_luaS_index(value);
-make_luaS_index(width);
-make_luaS_index(writable);
-make_luaS_index(xoffset);
-make_luaS_index(xyz_zoom);
-make_luaS_index(yoffset);
-
-make_luaS_index(additional);
-make_luaS_index(cal_expand_ratio);
-make_luaS_index(exactly);
-make_luaS_index(subst_ex_font);
-
-make_luaS_index(TLT);
-make_luaS_index(TRT);
-make_luaS_index(LTL);
-make_luaS_index(RTT);
-
-make_luaS_index(pTLT);
-make_luaS_index(pTRT);
-make_luaS_index(pLTL);
-make_luaS_index(pRTT);
-
-make_luaS_index(mTLT);
-make_luaS_index(mTRT);
-make_luaS_index(mLTL);
-make_luaS_index(mRTT);
-
-static void initialize_luaS_indexes(lua_State * L)
-{
-    init_luaS_index(luatex_node);
-
-    init_luaS_index(accent);
-    init_luaS_index(action_id);
-    init_luaS_index(action);
-    init_luaS_index(action_type);
-    init_luaS_index(area);
-    init_luaS_index(attr);
-    init_luaS_index(best_ins_ptr);
-    init_luaS_index(bot_accent);
-    init_luaS_index(box_left);
-    init_luaS_index(box_left_width);
-    init_luaS_index(box_right);
-    init_luaS_index(box_right_width);
-    init_luaS_index(broken_ins);
-    init_luaS_index(broken_ptr);
-    init_luaS_index(char);
-    init_luaS_index(class);
-    init_luaS_index(command);
-    init_luaS_index(components);
-    init_luaS_index(cost);
-    init_luaS_index(count);
-    init_luaS_index(data);
-    init_luaS_index(degree);
-    init_luaS_index(delim);
-    init_luaS_index(denom);
-    init_luaS_index(depth);
-    init_luaS_index(dest_id);
-    init_luaS_index(dest_type);
-    init_luaS_index(dir);
-    init_luaS_index(dir_h);
-    init_luaS_index(display);
-    init_luaS_index(dvi_ptr);
-    init_luaS_index(expansion_factor);
-    init_luaS_index(ext);
-    init_luaS_index(fam);
-    init_luaS_index(fast);
-    init_luaS_index(file);
-    init_luaS_index(font);
-    init_luaS_index(global);
-    init_luaS_index(glue_order);
-    init_luaS_index(glue_set);
-    init_luaS_index(glue_sign);
-    init_luaS_index(glyph);
-    init_luaS_index(head);
-    init_luaS_index(height);
-    init_luaS_index(id);
-    init_luaS_index(index);
-    init_luaS_index(kern);
-    init_luaS_index(lang);
-    init_luaS_index(large_char);
-    init_luaS_index(large_fam);
-    init_luaS_index(last_ins_ptr);
-    init_luaS_index(leader);
-    init_luaS_index(left);
-    init_luaS_index(level);
-    init_luaS_index(link_attr);
-    init_luaS_index(list);
-    init_luaS_index(mark);
-    init_luaS_index(mode);
-    init_luaS_index(name);
-    init_luaS_index(named_id);
-    init_luaS_index(new_window);
-    init_luaS_index(next);
-    init_luaS_index(nucleus);
-    init_luaS_index(num);
-    init_luaS_index(number);
-    init_luaS_index(objnum);
-    init_luaS_index(pen_broken);
-    init_luaS_index(pen_inter);
-    init_luaS_index(penalty);
-    init_luaS_index(post);
-    init_luaS_index(pre);
-    init_luaS_index(prev);
-    init_luaS_index(ref_count);
-    init_luaS_index(reg);
-    init_luaS_index(replace);
-    init_luaS_index(right);
-    init_luaS_index(script);
-    init_luaS_index(scriptscript);
-    init_luaS_index(shift);
-    init_luaS_index(shrink);
-    init_luaS_index(shrink_order);
-    init_luaS_index(small_char);
-    init_luaS_index(small_fam);
-    init_luaS_index(spec);
-    init_luaS_index(stack);
-    init_luaS_index(stream);
-    init_luaS_index(stretch);
-    init_luaS_index(stretch_order);
-    init_luaS_index(string);
-    init_luaS_index(style);
-    init_luaS_index(sub);
-    init_luaS_index(subtype);
-    init_luaS_index(sup);
-    init_luaS_index(surround);
-    init_luaS_index(text);
-    init_luaS_index(thread_attr);
-    init_luaS_index(thread_id);
-    init_luaS_index(transform);
-    init_luaS_index(type);
-    init_luaS_index(uchyph);
-    init_luaS_index(user_id);
-    init_luaS_index(value);
-    init_luaS_index(width);
-    init_luaS_index(writable);
-    init_luaS_index(xoffset);
-    init_luaS_index(xyz_zoom);
-    init_luaS_index(yoffset);
-
-    init_luaS_index(additional);
-    init_luaS_index(cal_expand_ratio);
-    init_luaS_index(exactly);
-    init_luaS_index(subst_ex_font);
-
-    init_luaS_index(TLT);
-    init_luaS_index(TRT);
-    init_luaS_index(LTL);
-    init_luaS_index(RTT);
-    init_luaS_index_s(pTLT,"+TLT");
-    init_luaS_index_s(pTRT,"+TRT");
-    init_luaS_index_s(pLTL,"+LTL");
-    init_luaS_index_s(pRTT,"+RTT");
-    init_luaS_index_s(mTLT,"-TLT");
-    init_luaS_index_s(mTRT,"-TRT");
-    init_luaS_index_s(mLTL,"-LTL");
-    init_luaS_index_s(mRTT,"-RTT");
-
-}
-
 /* maybe these qualify as macros, not functions */
 
 static halfword *maybe_isnode(lua_State * L, int ud)
@@ -566,7 +286,7 @@ halfword *check_isnode(lua_State * L, int ud)
     halfword *p = maybe_isnode(L, ud);
     if (p != NULL)
         return p;
-    pdftex_fail("There should have been a lua <node> here, not an object with type %s!", luaL_typename(L, ud));
+    luatex_fail("There should have been a lua <node> here, not an object with type %s!", luaL_typename(L, ud));
     return NULL;
 }
 
@@ -1349,7 +1069,7 @@ static int lua_nodelib_remove(lua_State * L)
     current = *(check_isnode(L, 2));
     if (head == current) {
       if (alink(current)){
-        vlink(alink(current)) = vlink(current); // vlink(prev) = next 
+        vlink(alink(current)) = vlink(current); // vlink(prev) = next
       }
       if (vlink(current)){
         alink( vlink(current)) = alink(current); // alink(next) = prev
@@ -1401,7 +1121,7 @@ static int lua_nodelib_direct_remove(lua_State * L)
     }
     if (head == current) {
       if (alink(current)){
-        vlink( alink(current) ) = vlink(current); // vlink(prev) = next 
+        vlink( alink(current) ) = vlink(current); // vlink(prev) = next
       }
       if (vlink(current)){
         alink( vlink(current) ) = alink(current); // alink(next) = prev
@@ -1597,7 +1317,9 @@ static int lua_nodelib_direct_insert_after(lua_State * L)
 }
 
 /* node.copy_list */
-
+/* hh-ls: we need to use an intermediate variable as otherwise target is used in the loop
+and subfields get overwritten (or something like that) which results in crashes and
+unexpected side effects */
 static int lua_nodelib_copy_list(lua_State * L)
 {
     halfword n, s = null;
@@ -1608,11 +1330,14 @@ static int lua_nodelib_copy_list(lua_State * L)
     if ((lua_gettop(L) > 1) && (!lua_isnil(L,2)))
         s = *check_isnode(L, 2);
     m = do_copy_node_list(n, s);
-    lua_pushnumber(L, m);
-    lua_nodelib_push(L);
+//    lua_pushnumber(L, m);
+//    lua_nodelib_push(L);
+    lua_nodelib_push_fast(L,m);
     return 1;
+
 }
 
+
 /* node.direct.copy_list */
 
 static int lua_nodelib_direct_copy_list(lua_State * L)
@@ -1742,13 +1467,13 @@ static int lua_nodelib_hpack(lua_State * L)
         if (lua_gettop(L) > 2) {
             if (lua_type(L, 3) == LUA_TSTRING) {
                 s = lua_tostring(L, 3);
-                if (luaS_ptr_eq(s, additional)) {
+                if (lua_key_eq(s, additional)) {
                     m = 1;
-                } else if (luaS_ptr_eq(s, exactly)) {
+                } else if (lua_key_eq(s, exactly)) {
                     m = 0;
-                } else if (luaS_ptr_eq(s, cal_expand_ratio)) {
+                } else if (lua_key_eq(s, cal_expand_ratio)) {
                     m = 2;
-                } else if (luaS_ptr_eq(s, subst_ex_font)) {
+                } else if (lua_key_eq(s, subst_ex_font)) {
                     m = 3;
                 } else {
                     luaL_error(L, "3rd argument should be either additional or exactly");
@@ -1789,13 +1514,13 @@ static int lua_nodelib_direct_hpack(lua_State * L)
         if (lua_gettop(L) > 2) {
             if (lua_type(L, 3) == LUA_TSTRING) {
                 s = lua_tostring(L, 3);
-                if (luaS_ptr_eq(s, additional)) {
+                if (lua_key_eq(s, additional)) {
                     m = 1;
-                } else if (luaS_ptr_eq(s, exactly)) {
+                } else if (lua_key_eq(s, exactly)) {
                     m = 0;
-                } else if (luaS_ptr_eq(s, cal_expand_ratio)) {
+                } else if (lua_key_eq(s, cal_expand_ratio)) {
                     m = 2;
-                } else if (luaS_ptr_eq(s, subst_ex_font)) {
+                } else if (lua_key_eq(s, subst_ex_font)) {
                     m = 3;
                 } else {
                     luaL_error(L, "3rd argument should be either additional or exactly");
@@ -1836,9 +1561,9 @@ static int lua_nodelib_vpack(lua_State * L)
         if (lua_gettop(L) > 2) {
             if (lua_type(L, 3) == LUA_TSTRING) {
                 s = lua_tostring(L, 3);
-                if (luaS_ptr_eq(s, additional)) {
+                if (lua_key_eq(s, additional)) {
                     m = 1;
-                } else if (luaS_ptr_eq(s, exactly)) {
+                } else if (lua_key_eq(s, exactly)) {
                     m = 0;
                 } else {
                     luaL_error(L, "3rd argument should be either additional or exactly");
@@ -1881,9 +1606,9 @@ static int lua_nodelib_direct_vpack(lua_State * L)
         if (lua_gettop(L) > 2) {
             if (lua_type(L, 3) == LUA_TSTRING) {
                 s = lua_tostring(L, 3);
-                if (luaS_ptr_eq(s, additional)) {
+                if (lua_key_eq(s, additional)) {
                     m = 1;
-                } else if (luaS_ptr_eq(s, exactly)) {
+                } else if (lua_key_eq(s, exactly)) {
                     m = 0;
                 } else {
                     luaL_error(L, "3rd argument should be either additional or exactly");
@@ -2048,19 +1773,19 @@ static int get_node_field_id(lua_State * L, int n, int node)
     if (s == NULL)
         return -2;
 
-    if (luaS_ptr_eq(s, next)) {
+    if (lua_key_eq(s, next)) {
         return 0;
-    } else if (luaS_ptr_eq(s, id)) {
+    } else if (lua_key_eq(s, id)) {
         return 1;
-    } else if (luaS_ptr_eq(s, subtype)) {
+    } else if (lua_key_eq(s, subtype)) {
         if (nodetype_has_subtype(t)) {
             return 2;
         }
-    } else if (luaS_ptr_eq(s, attr)) {
+    } else if (lua_key_eq(s, attr)) {
         if (nodetype_has_attributes(t)) {
             return 3;
         }
-    } else if (luaS_ptr_eq(s, prev)) {
+    } else if (lua_key_eq(s, prev)) {
         if (nodetype_has_prev(t)) {
             return -1;
         }
@@ -2070,7 +1795,7 @@ static int get_node_field_id(lua_State * L, int n, int node)
         if (t == whatsit_node) {
             fields = whatsit_node_data[subtype(node)].fields;
         }
-        if (luaS_ptr_eq(s, list)) {
+        if (lua_key_eq(s, list)) {
             /* head and list are equivalent; we don't catch extra virtual fields */
             s = luaS_head_ptr;
         }
@@ -2732,33 +2457,31 @@ static void lua_nodelib_getfield_whatsit(lua_State * L, int n, const char *s)
     t = subtype(n);
 
     if (t == dir_node) {
-        if (luaS_ptr_eq(s, dir)) {
+        if (lua_key_eq(s, dir)) {
             nodelib_pushdir(L, dir_dir(n), true);
-        } else if (luaS_ptr_eq(s, level)) {
+        } else if (lua_key_eq(s, level)) {
             lua_pushnumber(L, dir_level(n));
-        } else if (luaS_ptr_eq(s, dvi_ptr)) {
+        } else if (lua_key_eq(s, dvi_ptr)) {
             lua_pushnumber(L, dir_dvi_ptr(n));
-        } else if (luaS_ptr_eq(s, dir_h)) {
+        } else if (lua_key_eq(s, dir_h)) {
             lua_pushnumber(L, dir_dvi_h(n));
         } else {
             lua_pushnil(L);
         }
     } else if (t == user_defined_node) {
-        if (luaS_ptr_eq(s, user_id)) {
+        if (lua_key_eq(s, user_id)) {
             lua_pushnumber(L, user_node_id(n));
-        } else if (luaS_ptr_eq(s, type)) {
+        } else if (lua_key_eq(s, type)) {
             lua_pushnumber(L, user_node_type(n));
-        } else if (luaS_ptr_eq(s, value)) {
+        } else if (lua_key_eq(s, value)) {
             switch (user_node_type(n)) {
             case 'a':
-                /* fast_metatable(n) */
                 nodelib_pushlist(L, user_node_value(n));
                 break;
             case 'd':
                 lua_pushnumber(L, user_node_value(n));
                 break;
             case 'n':
-                /* fast_metatable(n) */
                 nodelib_pushlist(L, user_node_value(n));
                 break;
             case 's':
@@ -2775,29 +2498,29 @@ static void lua_nodelib_getfield_whatsit(lua_State * L, int n, const char *s)
             lua_pushnil(L);
         }
     } else if (t == local_par_node) {
-        if (luaS_ptr_eq(s, pen_inter)) {
+        if (lua_key_eq(s, pen_inter)) {
             lua_pushnumber(L, local_pen_inter(n));
-        } else if (luaS_ptr_eq(s, pen_broken)) {
+        } else if (lua_key_eq(s, pen_broken)) {
             lua_pushnumber(L, local_pen_broken(n));
-        } else if (luaS_ptr_eq(s, dir)) {
+        } else if (lua_key_eq(s, dir)) {
             nodelib_pushdir(L, local_par_dir(n), false);
-        } else if (luaS_ptr_eq(s, box_left)) {
+        } else if (lua_key_eq(s, box_left)) {
             /* can be: fast_metatable_or_nil(local_box_left(n)) */
             nodelib_pushlist(L, local_box_left(n));
-        } else if (luaS_ptr_eq(s, box_left_width)) {
+        } else if (lua_key_eq(s, box_left_width)) {
             lua_pushnumber(L, local_box_left_width(n));
-        } else if (luaS_ptr_eq(s, box_right)) {
+        } else if (lua_key_eq(s, box_right)) {
             /* can be: fast_metatable_or_nil(local_box_right(n)) */
             nodelib_pushlist(L, local_box_right(n));
-        } else if (luaS_ptr_eq(s, box_right_width)) {
+        } else if (lua_key_eq(s, box_right_width)) {
             lua_pushnumber(L, local_box_right_width(n));
         } else {
             lua_pushnil(L);
         }
     } else if (t == pdf_literal_node) {
-        if (luaS_ptr_eq(s, mode)) {
+        if (lua_key_eq(s, mode)) {
             lua_pushnumber(L, pdf_literal_mode(n));
-        } else if (luaS_ptr_eq(s, data)) {
+        } else if (lua_key_eq(s, data)) {
             if (pdf_literal_type(n) == lua_refid_literal) {
                 lua_rawgeti(Luas, LUA_REGISTRYINDEX, pdf_literal_data(n));
             } else {
@@ -2807,9 +2530,9 @@ static void lua_nodelib_getfield_whatsit(lua_State * L, int n, const char *s)
             lua_pushnil(L);
         }
     } else if (t == late_lua_node) {
-        if (luaS_ptr_eq(s, name)) {
+        if (lua_key_eq(s, name)) {
             tokenlist_to_luastring(L, late_lua_name(n));
-        } else if (luaS_ptr_eq(s, data) || luaS_ptr_eq(s, string)) {
+        } else if (lua_key_eq(s, data) || lua_key_eq(s, string)) {
             if (late_lua_type(n) == lua_refid_literal) {
                 lua_rawgeti(Luas, LUA_REGISTRYINDEX, late_lua_data(n));
             } else {
@@ -2819,154 +2542,154 @@ static void lua_nodelib_getfield_whatsit(lua_State * L, int n, const char *s)
             lua_pushnil(L);
         }
     } else if (t == pdf_annot_node) {
-        if (luaS_ptr_eq(s, width)) {
+        if (lua_key_eq(s, width)) {
             lua_pushnumber(L, width(n));
-        } else if (luaS_ptr_eq(s, depth)) {
+        } else if (lua_key_eq(s, depth)) {
             lua_pushnumber(L, depth(n));
-        } else if (luaS_ptr_eq(s, height)) {
+        } else if (lua_key_eq(s, height)) {
             lua_pushnumber(L, height(n));
-        } else if (luaS_ptr_eq(s, objnum)) {
+        } else if (lua_key_eq(s, objnum)) {
             lua_pushnumber(L, pdf_annot_objnum(n));
-        } else if (luaS_ptr_eq(s, data)) {
+        } else if (lua_key_eq(s, data)) {
             tokenlist_to_luastring(L, pdf_annot_data(n));
         } else {
             lua_pushnil(L);
         }
     } else if (t == pdf_dest_node) {
-        if (luaS_ptr_eq(s, width)) {
+        if (lua_key_eq(s, width)) {
             lua_pushnumber(L, width(n));
-        } else if (luaS_ptr_eq(s, depth)) {
+        } else if (lua_key_eq(s, depth)) {
             lua_pushnumber(L, depth(n));
-        } else if (luaS_ptr_eq(s, height)) {
+        } else if (lua_key_eq(s, height)) {
             lua_pushnumber(L, height(n));
-        } else if (luaS_ptr_eq(s, named_id)) {
+        } else if (lua_key_eq(s, named_id)) {
             lua_pushnumber(L, pdf_dest_named_id(n));
-        } else if (luaS_ptr_eq(s, dest_id)) {
+        } else if (lua_key_eq(s, dest_id)) {
             if (pdf_dest_named_id(n) == 1)
                 tokenlist_to_luastring(L, pdf_dest_id(n));
             else
                 lua_pushnumber(L, pdf_dest_id(n));
-        } else if (luaS_ptr_eq(s, dest_type)) {
+        } else if (lua_key_eq(s, dest_type)) {
             lua_pushnumber(L, pdf_dest_type(n));
-        } else if (luaS_ptr_eq(s, xyz_zoom)) {
+        } else if (lua_key_eq(s, xyz_zoom)) {
             lua_pushnumber(L, pdf_dest_xyz_zoom(n));
-        } else if (luaS_ptr_eq(s, objnum)) {
+        } else if (lua_key_eq(s, objnum)) {
             lua_pushnumber(L, pdf_dest_objnum(n));
         } else {
             lua_pushnil(L);
         }
     } else if (t == pdf_setmatrix_node) {
-        if (luaS_ptr_eq(s, data)) {
+        if (lua_key_eq(s, data)) {
             tokenlist_to_luastring(L, pdf_setmatrix_data(n));
         } else {
             lua_pushnil(L);
         }
     } else if (t == pdf_colorstack_node) {
-        if (luaS_ptr_eq(s, stack)) {
+        if (lua_key_eq(s, stack)) {
             lua_pushnumber(L, pdf_colorstack_stack(n));
-        } else if (luaS_ptr_eq(s, command)) {
+        } else if (lua_key_eq(s, command)) {
             lua_pushnumber(L, pdf_colorstack_cmd(n));
-        } else if (luaS_ptr_eq(s, data)) {
+        } else if (lua_key_eq(s, data)) {
             tokenlist_to_luastring(L, pdf_colorstack_data(n));
         } else {
             lua_pushnil(L);
         }
     } else if (t == pdf_refobj_node) {
-        if (luaS_ptr_eq(s, objnum)) {
+        if (lua_key_eq(s, objnum)) {
             lua_pushnumber(L, pdf_obj_objnum(n));
         } else {
             lua_pushnil(L);
         }
     } else if (t == pdf_refxform_node) {
-        if (luaS_ptr_eq(s, width)) {
+        if (lua_key_eq(s, width)) {
             lua_pushnumber(L, width(n));
-        } else if (luaS_ptr_eq(s, depth)) {
+        } else if (lua_key_eq(s, depth)) {
             lua_pushnumber(L, depth(n));
-        } else if (luaS_ptr_eq(s, height)) {
+        } else if (lua_key_eq(s, height)) {
             lua_pushnumber(L, height(n));
-        } else if (luaS_ptr_eq(s, objnum)) {
+        } else if (lua_key_eq(s, objnum)) {
             lua_pushnumber(L, pdf_xform_objnum(n));
         } else {
             lua_pushnil(L);
         }
     } else if (t == pdf_refximage_node) {
-        if (luaS_ptr_eq(s, width)) {
+        if (lua_key_eq(s, width)) {
             lua_pushnumber(L, width(n));
-        } else if (luaS_ptr_eq(s, depth)) {
+        } else if (lua_key_eq(s, depth)) {
             lua_pushnumber(L, depth(n));
-        } else if (luaS_ptr_eq(s, height)) {
+        } else if (lua_key_eq(s, height)) {
             lua_pushnumber(L, height(n));
-        } else if (luaS_ptr_eq(s, transform)) {
+        } else if (lua_key_eq(s, transform)) {
             lua_pushnumber(L, pdf_ximage_transform(n));
-        } else if (luaS_ptr_eq(s, index)) {
+        } else if (lua_key_eq(s, index)) {
             lua_pushnumber(L, pdf_ximage_index(n));
         } else {
             lua_pushnil(L);
         }
     } else if (t == write_node) {
-        if (luaS_ptr_eq(s, stream)) {
+        if (lua_key_eq(s, stream)) {
             lua_pushnumber(L, write_stream(n));
-        } else if (luaS_ptr_eq(s, data)) {
+        } else if (lua_key_eq(s, data)) {
             tokenlist_to_lua(L, write_tokens(n));
         } else {
             lua_pushnil(L);
         }
     } else if (t == special_node) {
-        if (luaS_ptr_eq(s, data)) {
+        if (lua_key_eq(s, data)) {
             tokenlist_to_luastring(L, write_tokens(n));
         } else {
             lua_pushnil(L);
         }
     } else if (t == pdf_start_link_node) {
-        if (luaS_ptr_eq(s, width)) {
+        if (lua_key_eq(s, width)) {
             lua_pushnumber(L, width(n));
-        } else if (luaS_ptr_eq(s, depth)) {
+        } else if (lua_key_eq(s, depth)) {
             lua_pushnumber(L, depth(n));
-        } else if (luaS_ptr_eq(s, height)) {
+        } else if (lua_key_eq(s, height)) {
             lua_pushnumber(L, height(n));
-        } else if (luaS_ptr_eq(s, objnum)) {
+        } else if (lua_key_eq(s, objnum)) {
             lua_pushnumber(L, pdf_link_objnum(n));
-        } else if (luaS_ptr_eq(s, link_attr)) {
+        } else if (lua_key_eq(s, link_attr)) {
             tokenlist_to_luastring(L, pdf_link_attr(n));
-        } else if (luaS_ptr_eq(s, action)) {
+        } else if (lua_key_eq(s, action)) {
             nodelib_pushaction(L, pdf_link_action(n));
         } else {
             lua_pushnil(L);
         }
     } else if ((t == pdf_thread_node) || (t == pdf_start_thread_node)) {
-        if (luaS_ptr_eq(s, width)) {
+        if (lua_key_eq(s, width)) {
             lua_pushnumber(L, width(n));
-        } else if (luaS_ptr_eq(s, depth)) {
+        } else if (lua_key_eq(s, depth)) {
             lua_pushnumber(L, depth(n));
-        } else if (luaS_ptr_eq(s, height)) {
+        } else if (lua_key_eq(s, height)) {
             lua_pushnumber(L, height(n));
-        } else if (luaS_ptr_eq(s, named_id)) {
+        } else if (lua_key_eq(s, named_id)) {
             lua_pushnumber(L, pdf_thread_named_id(n));
-        } else if (luaS_ptr_eq(s, thread_id)) {
+        } else if (lua_key_eq(s, thread_id)) {
             if (pdf_thread_named_id(n) == 1) {
                 tokenlist_to_luastring(L, pdf_thread_id(n));
             } else {
                 lua_pushnumber(L, pdf_thread_id(n));
             }
-        } else if (luaS_ptr_eq(s, thread_attr)) {
+        } else if (lua_key_eq(s, thread_attr)) {
             tokenlist_to_luastring(L, pdf_thread_attr(n));
         } else {
             lua_pushnil(L);
         }
     } else if (t == open_node) {
-        if (luaS_ptr_eq(s, stream)) {
+        if (lua_key_eq(s, stream)) {
             lua_pushnumber(L, write_stream(n));
-        } else if (luaS_ptr_eq(s, name)) {
+        } else if (lua_key_eq(s, name)) {
             nodelib_pushstring(L, open_name(n));
-        } else if (luaS_ptr_eq(s, area)) {
+        } else if (lua_key_eq(s, area)) {
             nodelib_pushstring(L, open_area(n));
-        } else if (luaS_ptr_eq(s, ext)) {
+        } else if (lua_key_eq(s, ext)) {
             nodelib_pushstring(L, open_ext(n));
         } else {
             lua_pushnil(L);
         }
     } else if (t == close_node) {
-        if (luaS_ptr_eq(s, stream)) {
+        if (lua_key_eq(s, stream)) {
             lua_pushnumber(L, write_stream(n));
         } else {
             lua_pushnil(L);
@@ -3033,13 +2756,13 @@ static int lua_nodelib_fast_getfield(lua_State * L)
 
     s = lua_tostring(L, 2);
 
-    if (luaS_ptr_eq(s, id)) {
+    if (lua_key_eq(s, id)) {
         lua_pushnumber(L, t);
-    } else if (luaS_ptr_eq(s, next)) {
+    } else if (lua_key_eq(s, next)) {
         fast_metatable_or_nil(vlink(n));
-    } else if (luaS_ptr_eq(s, prev)) {
+    } else if (lua_key_eq(s, prev)) {
         fast_metatable_or_nil(alink(n));
-    } else if (luaS_ptr_eq(s, attr)) {
+    } else if (lua_key_eq(s, attr)) {
         if (! nodetype_has_attributes(t)) {
             lua_pushnil(L);
         } else {
@@ -3047,404 +2770,404 @@ static int lua_nodelib_fast_getfield(lua_State * L)
         }
     } else if (t == glyph_node) {
       /* candidates: fontchar (font,char) whd (width,height,depth) */
-        if (luaS_ptr_eq(s, subtype)) {
+        if (lua_key_eq(s, subtype)) {
             lua_pushnumber(L, subtype(n));
-        } else if (luaS_ptr_eq(s, font)) {
+        } else if (lua_key_eq(s, font)) {
             lua_pushnumber(L, font(n));
-        } else if (luaS_ptr_eq(s, char)) {
+        } else if (lua_key_eq(s, char)) {
             lua_pushnumber(L, character(n));
-        } else if (luaS_ptr_eq(s, xoffset)) {
+        } else if (lua_key_eq(s, xoffset)) {
             lua_pushnumber(L, x_displace(n));
-        } else if (luaS_ptr_eq(s, yoffset)) {
+        } else if (lua_key_eq(s, yoffset)) {
             lua_pushnumber(L, y_displace(n));
-        } else if (luaS_ptr_eq(s, width)) {
+        } else if (lua_key_eq(s, width)) {
             lua_pushnumber(L, char_width(font(n),character(n)));
-        } else if (luaS_ptr_eq(s, height)) {
+        } else if (lua_key_eq(s, height)) {
             lua_pushnumber(L, char_height(font(n),character(n)));
-        } else if (luaS_ptr_eq(s, depth)) {
+        } else if (lua_key_eq(s, depth)) {
             lua_pushnumber(L, char_depth(font(n),character(n)));
-        } else if (luaS_ptr_eq(s, expansion_factor)) {
+        } else if (lua_key_eq(s, expansion_factor)) {
             lua_pushnumber(L, ex_glyph(n));
-        } else if (luaS_ptr_eq(s, components)) {
+        } else if (lua_key_eq(s, components)) {
             fast_metatable_or_nil(lig_ptr(n));
-        } else if (luaS_ptr_eq(s, lang)) {
+        } else if (lua_key_eq(s, lang)) {
             lua_pushnumber(L, char_lang(n));
-        } else if (luaS_ptr_eq(s, left)) {
+        } else if (lua_key_eq(s, left)) {
             lua_pushnumber(L, char_lhmin(n));
-        } else if (luaS_ptr_eq(s, right)) {
+        } else if (lua_key_eq(s, right)) {
             lua_pushnumber(L, char_rhmin(n));
-        } else if (luaS_ptr_eq(s, uchyph)) {
+        } else if (lua_key_eq(s, uchyph)) {
             lua_pushnumber(L, char_uchyph(n));
         } else {
             lua_pushnil(L);
         }
     } else if ((t == hlist_node) || (t == vlist_node)) {
       /* candidates: whd (width,height,depth) */
-        if (luaS_ptr_eq(s, subtype)) {
+        if (lua_key_eq(s, subtype)) {
             lua_pushnumber(L, subtype(n));
-        } else if (luaS_ptr_eq(s, list) || luaS_ptr_eq(s, head)) {
+        } else if (lua_key_eq(s, list) || lua_key_eq(s, head)) {
             fast_metatable_or_nil_alink(list_ptr(n));
-        } else if (luaS_ptr_eq(s, width)) {
+        } else if (lua_key_eq(s, width)) {
             lua_pushnumber(L, width(n));
-        } else if (luaS_ptr_eq(s, height)) {
+        } else if (lua_key_eq(s, height)) {
             lua_pushnumber(L, height(n));
-        } else if (luaS_ptr_eq(s, depth)) {
+        } else if (lua_key_eq(s, depth)) {
             lua_pushnumber(L, depth(n));
-        } else if (luaS_ptr_eq(s, dir)) {
+        } else if (lua_key_eq(s, dir)) {
             nodelib_pushdir(L, box_dir(n), false);
-        } else if (luaS_ptr_eq(s, shift)) {
+        } else if (lua_key_eq(s, shift)) {
             lua_pushnumber(L, shift_amount(n));
-        } else if (luaS_ptr_eq(s, glue_order)) {
+        } else if (lua_key_eq(s, glue_order)) {
             lua_pushnumber(L, glue_order(n));
-        } else if (luaS_ptr_eq(s, glue_sign)) {
+        } else if (lua_key_eq(s, glue_sign)) {
             lua_pushnumber(L, glue_sign(n));
-        } else if (luaS_ptr_eq(s, glue_set)) {
+        } else if (lua_key_eq(s, glue_set)) {
             lua_pushnumber(L, (double) glue_set(n));
         } else {
             lua_pushnil(L);
         }
     } else if (t == disc_node) {
-        if (luaS_ptr_eq(s, subtype)) {
+        if (lua_key_eq(s, subtype)) {
             lua_pushnumber(L, subtype(n));
-        } else if (luaS_ptr_eq(s, pre)) {
+        } else if (lua_key_eq(s, pre)) {
             fast_metatable_or_nil(vlink(pre_break(n)));
-        } else if (luaS_ptr_eq(s, post)) {
+        } else if (lua_key_eq(s, post)) {
             fast_metatable_or_nil(vlink(post_break(n)));
-        } else if (luaS_ptr_eq(s, replace)) {
+        } else if (lua_key_eq(s, replace)) {
             fast_metatable_or_nil(vlink(no_break(n)));
         } else {
             lua_pushnil(L);
         }
     } else if (t == glue_node) {
-        if (luaS_ptr_eq(s, subtype)) {
+        if (lua_key_eq(s, subtype)) {
             lua_pushnumber(L, subtype(n));
-        } else if (luaS_ptr_eq(s, spec)) {
+        } else if (lua_key_eq(s, spec)) {
             nodelib_pushspec(L, glue_ptr(n));
-        } else if (luaS_ptr_eq(s, leader)) {
+        } else if (lua_key_eq(s, leader)) {
             fast_metatable_or_nil(leader_ptr(n));
         } else {
             lua_pushnil(L);
         }
     } else if (t == glue_spec_node) {
-        if (luaS_ptr_eq(s, subtype)) {
+        if (lua_key_eq(s, subtype)) {
             lua_pushnumber(L, 0); /* dummy, the only one that prevents move up */
-        } else if (luaS_ptr_eq(s, width)) {
+        } else if (lua_key_eq(s, width)) {
             lua_pushnumber(L, width(n));
-        } else if (luaS_ptr_eq(s, stretch)) {
+        } else if (lua_key_eq(s, stretch)) {
             lua_pushnumber(L, stretch(n));
-        } else if (luaS_ptr_eq(s, shrink)) {
+        } else if (lua_key_eq(s, shrink)) {
             lua_pushnumber(L, shrink(n));
-        } else if (luaS_ptr_eq(s, stretch_order)) {
+        } else if (lua_key_eq(s, stretch_order)) {
             lua_pushnumber(L, stretch_order(n));
-        } else if (luaS_ptr_eq(s, shrink_order)) {
+        } else if (lua_key_eq(s, shrink_order)) {
             lua_pushnumber(L, shrink_order(n));
-        } else if (luaS_ptr_eq(s, ref_count)) {
+        } else if (lua_key_eq(s, ref_count)) {
             lua_pushnumber(L, glue_ref_count(n));
-        } else if (luaS_ptr_eq(s, writable)) {
+        } else if (lua_key_eq(s, writable)) {
             lua_pushboolean(L, valid_node(n));
         } else {
             lua_pushnil(L);
         }
     } else if (t == kern_node) {
-        if (luaS_ptr_eq(s, subtype)) {
+        if (lua_key_eq(s, subtype)) {
             lua_pushnumber(L, subtype(n));
-        } else if (luaS_ptr_eq(s, kern)) {
+        } else if (lua_key_eq(s, kern)) {
             lua_pushnumber(L, width(n));
-        } else if (luaS_ptr_eq(s, expansion_factor)) {
+        } else if (lua_key_eq(s, expansion_factor)) {
             lua_pushnumber(L, ex_kern(n));
         } else {
             lua_pushnil(L);
         }
     } else if (t == penalty_node) {
-        if (luaS_ptr_eq(s, subtype)) {
+        if (lua_key_eq(s, subtype)) {
             lua_pushnumber(L, subtype(n));
-        } else if (luaS_ptr_eq(s, penalty)) {
+        } else if (lua_key_eq(s, penalty)) {
             lua_pushnumber(L, penalty(n));
         } else {
             lua_pushnil(L);
         }
     } else if (t == rule_node) {
         /* candidates: whd (width,height,depth) */
-        if (luaS_ptr_eq(s, subtype)) {
+        if (lua_key_eq(s, subtype)) {
             lua_pushnumber(L, subtype(n));
-        } else if (luaS_ptr_eq(s, width)) {
+        } else if (lua_key_eq(s, width)) {
             lua_pushnumber(L, width(n));
-        } else if (luaS_ptr_eq(s, height)) {
+        } else if (lua_key_eq(s, height)) {
             lua_pushnumber(L, height(n));
-        } else if (luaS_ptr_eq(s, depth)) {
+        } else if (lua_key_eq(s, depth)) {
             lua_pushnumber(L, depth(n));
-        } else if (luaS_ptr_eq(s, dir)) {
+        } else if (lua_key_eq(s, dir)) {
             nodelib_pushdir(L, rule_dir(n), false);
         } else {
             lua_pushnil(L);
         }
     } else if (t == whatsit_node) {
-        if (luaS_ptr_eq(s, subtype)) {
+        if (lua_key_eq(s, subtype)) {
             lua_pushnumber(L, subtype(n));
         } else {
             lua_nodelib_getfield_whatsit(L, n, s);
         }
     } else if (t == simple_noad) {
-        if (luaS_ptr_eq(s, subtype)) {
+        if (lua_key_eq(s, subtype)) {
             lua_pushnumber(L, subtype(n));
-        } else if (luaS_ptr_eq(s, nucleus)) {
+        } else if (lua_key_eq(s, nucleus)) {
             fast_metatable_or_nil(nucleus(n));
-        } else if (luaS_ptr_eq(s, sub)) {
+        } else if (lua_key_eq(s, sub)) {
             fast_metatable_or_nil(subscr(n));
-        } else if (luaS_ptr_eq(s, sup)) {
+        } else if (lua_key_eq(s, sup)) {
             fast_metatable_or_nil(supscr(n));
         } else {
             lua_pushnil(L);
         }
     } else if ((t == math_char_node) || (t == math_text_char_node)) {
         /* candidates: famchar (fam,char) */
-        if (luaS_ptr_eq(s, subtype)) {
+        if (lua_key_eq(s, subtype)) {
             lua_pushnumber(L, subtype(n));
-        } else if (luaS_ptr_eq(s, fam)) {
+        } else if (lua_key_eq(s, fam)) {
             lua_pushnumber(L, math_fam(n));
-        } else if (luaS_ptr_eq(s, char)) {
+        } else if (lua_key_eq(s, char)) {
             lua_pushnumber(L, math_character(n));
         } else {
             lua_pushnil(L);
         }
     } else if (t == mark_node) {
-        if (luaS_ptr_eq(s, subtype)) {
+        if (lua_key_eq(s, subtype)) {
             lua_pushnumber(L, subtype(n));
-        } else if (luaS_ptr_eq(s, class)) {
+        } else if (lua_key_eq(s, class)) {
             lua_pushnumber(L, mark_class(n));
-        } else if (luaS_ptr_eq(s, mark)) {
+        } else if (lua_key_eq(s, mark)) {
             tokenlist_to_lua(L, mark_ptr(n));
         } else {
             lua_pushnil(L);
         }
     } else if (t == ins_node) {
-        if (luaS_ptr_eq(s, subtype)) {
+        if (lua_key_eq(s, subtype)) {
             lua_pushnumber(L, subtype(n));
-        } else if (luaS_ptr_eq(s, cost)) {
+        } else if (lua_key_eq(s, cost)) {
             lua_pushnumber(L, float_cost(n));
-        } else if (luaS_ptr_eq(s, depth)) {
+        } else if (lua_key_eq(s, depth)) {
             lua_pushnumber(L, depth(n));
-        } else if (luaS_ptr_eq(s, height)) {
+        } else if (lua_key_eq(s, height)) {
             lua_pushnumber(L, height(n));
-        } else if (luaS_ptr_eq(s, spec)) {
+        } else if (lua_key_eq(s, spec)) {
             nodelib_pushspec(L, split_top_ptr(n));
-        } else if ((luaS_ptr_eq(s, list)) || (luaS_ptr_eq(s, head))) {
+        } else if ((lua_key_eq(s, list)) || (lua_key_eq(s, head))) {
             fast_metatable_or_nil_alink(ins_ptr(n));
         } else {
             lua_pushnil(L);
         }
     } else if (t == math_node) {
-        if (luaS_ptr_eq(s, subtype)) {
+        if (lua_key_eq(s, subtype)) {
             lua_pushnumber(L, subtype(n));
-        } else if (luaS_ptr_eq(s, surround)) {
+        } else if (lua_key_eq(s, surround)) {
             lua_pushnumber(L, surround(n));
         } else {
             lua_pushnil(L);
         }
     } else if (t == fraction_noad) {
-        if (luaS_ptr_eq(s, subtype)) {
+        if (lua_key_eq(s, subtype)) {
             lua_pushnumber(L, subtype(n));
-        } else if (luaS_ptr_eq(s, width)) {
+        } else if (lua_key_eq(s, width)) {
             lua_pushnumber(L, thickness(n));
-        } else if (luaS_ptr_eq(s, num)) {
+        } else if (lua_key_eq(s, num)) {
             fast_metatable_or_nil(numerator(n));
-        } else if (luaS_ptr_eq(s, denom)) {
+        } else if (lua_key_eq(s, denom)) {
             fast_metatable_or_nil(denominator(n));
-        } else if (luaS_ptr_eq(s, left)) {
+        } else if (lua_key_eq(s, left)) {
             fast_metatable_or_nil(left_delimiter(n));
-        } else if (luaS_ptr_eq(s, right)) {
+        } else if (lua_key_eq(s, right)) {
             fast_metatable_or_nil(right_delimiter(n));
         } else {
             lua_pushnil(L);
         }
     } else if (t == style_node) {
-        if (luaS_ptr_eq(s, subtype)) {
+        if (lua_key_eq(s, subtype)) {
             lua_pushnumber(L, subtype(n));
-        } else if (luaS_ptr_eq(s, style)) {
+        } else if (lua_key_eq(s, style)) {
             lua_pushstring(L, math_style_names[subtype(n)]);
         } else {
             lua_pushnil(L);
         }
     } else if (t == accent_noad) {
-        if (luaS_ptr_eq(s, subtype)) {
+        if (lua_key_eq(s, subtype)) {
             lua_pushnumber(L, subtype(n));
-        } else if (luaS_ptr_eq(s, nucleus)) {
+        } else if (lua_key_eq(s, nucleus)) {
             fast_metatable_or_nil(nucleus(n));
-        } else if (luaS_ptr_eq(s, sub)) {
+        } else if (lua_key_eq(s, sub)) {
             fast_metatable_or_nil(subscr(n));
-        } else if (luaS_ptr_eq(s, sup)) {
+        } else if (lua_key_eq(s, sup)) {
             fast_metatable_or_nil(supscr(n));
-        } else if (luaS_ptr_eq(s, accent)) {
+        } else if (lua_key_eq(s, accent)) {
             fast_metatable_or_nil(accent_chr(n));
-        } else if (luaS_ptr_eq(s, bot_accent)) {
+        } else if (lua_key_eq(s, bot_accent)) {
             fast_metatable_or_nil(bot_accent_chr(n));
         } else {
             lua_pushnil(L);
         }
     } else if (t == fence_noad) {
-        if (luaS_ptr_eq(s, subtype)) {
+        if (lua_key_eq(s, subtype)) {
             lua_pushnumber(L, subtype(n));
-        } else if (luaS_ptr_eq(s, delim)) {
+        } else if (lua_key_eq(s, delim)) {
             fast_metatable_or_nil(delimiter(n));
         } else {
             lua_pushnil(L);
         }
     } else if (t == delim_node) {
-        if (luaS_ptr_eq(s, subtype)) {
+        if (lua_key_eq(s, subtype)) {
             lua_pushnumber(L, subtype(n));
-        } else if (luaS_ptr_eq(s, small_fam)) {
+        } else if (lua_key_eq(s, small_fam)) {
             lua_pushnumber(L, small_fam(n));
-        } else if (luaS_ptr_eq(s, small_char)) {
+        } else if (lua_key_eq(s, small_char)) {
             lua_pushnumber(L, small_char(n));
-        } else if (luaS_ptr_eq(s, large_fam)) {
+        } else if (lua_key_eq(s, large_fam)) {
             lua_pushnumber(L, large_fam(n));
-        } else if (luaS_ptr_eq(s, large_char)) {
+        } else if (lua_key_eq(s, large_char)) {
             lua_pushnumber(L, large_char(n));
         } else {
             lua_pushnil(L);
         }
     } else if ((t == sub_box_node) || (t == sub_mlist_node)) {
-        if (luaS_ptr_eq(s, subtype)) {
+        if (lua_key_eq(s, subtype)) {
             lua_pushnumber(L, subtype(n));
-        } else if ((luaS_ptr_eq(s, list)) || (luaS_ptr_eq(s, head))){
+        } else if ((lua_key_eq(s, list)) || (lua_key_eq(s, head))){
             fast_metatable_or_nil_alink(math_list(n));
         } else {
             lua_pushnil(L);
         }
     } else if (t == radical_noad) {
-        if (luaS_ptr_eq(s, subtype)) {
+        if (lua_key_eq(s, subtype)) {
             lua_pushnumber(L, subtype(n));
-        } else if (luaS_ptr_eq(s, nucleus)) {
+        } else if (lua_key_eq(s, nucleus)) {
             fast_metatable_or_nil(nucleus(n));
-        } else if (luaS_ptr_eq(s, sub)) {
+        } else if (lua_key_eq(s, sub)) {
             fast_metatable_or_nil(subscr(n));
-        } else if (luaS_ptr_eq(s, sup)) {
+        } else if (lua_key_eq(s, sup)) {
             fast_metatable_or_nil(supscr(n));
-        } else if (luaS_ptr_eq(s, left)) {
+        } else if (lua_key_eq(s, left)) {
             fast_metatable_or_nil(left_delimiter(n));
-        } else if (luaS_ptr_eq(s, degree)) {
+        } else if (lua_key_eq(s, degree)) {
             fast_metatable_or_nil(degree(n));
         } else {
             lua_pushnil(L);
         }
     } else if (t == margin_kern_node) {
-        if (luaS_ptr_eq(s, subtype)) {
+        if (lua_key_eq(s, subtype)) {
             lua_pushnumber(L, subtype(n));
-        } else if (luaS_ptr_eq(s, width)) {
+        } else if (lua_key_eq(s, width)) {
             lua_pushnumber(L, width(n));
-        } else if (luaS_ptr_eq(s, glyph)) {
+        } else if (lua_key_eq(s, glyph)) {
             fast_metatable_or_nil(margin_char(n));
         } else {
             lua_pushnil(L);
         }
     } else if (t == split_up_node) {
-        if (luaS_ptr_eq(s, subtype)) {
+        if (lua_key_eq(s, subtype)) {
             lua_pushnumber(L, subtype(n));
-        } else if (luaS_ptr_eq(s, last_ins_ptr)) {
+        } else if (lua_key_eq(s, last_ins_ptr)) {
             fast_metatable_or_nil(last_ins_ptr(n));
-        } else if (luaS_ptr_eq(s, best_ins_ptr)) {
+        } else if (lua_key_eq(s, best_ins_ptr)) {
             fast_metatable_or_nil(best_ins_ptr(n));
-        } else if (luaS_ptr_eq(s, broken_ptr)) {
+        } else if (lua_key_eq(s, broken_ptr)) {
             fast_metatable_or_nil(broken_ptr(n));
-        } else if (luaS_ptr_eq(s, broken_ins)) {
+        } else if (lua_key_eq(s, broken_ins)) {
             fast_metatable_or_nil(broken_ins(n));
         } else {
             lua_pushnil(L);
         }
     } else if (t == choice_node) {
-        if (luaS_ptr_eq(s, subtype)) {
+        if (lua_key_eq(s, subtype)) {
             lua_pushnumber(L, subtype(n));
-        } else if (luaS_ptr_eq(s, display)) {
+        } else if (lua_key_eq(s, display)) {
             fast_metatable_or_nil(display_mlist(n));
-        } else if (luaS_ptr_eq(s, text)) {
+        } else if (lua_key_eq(s, text)) {
             fast_metatable_or_nil(text_mlist(n));
-        } else if (luaS_ptr_eq(s, script)) {
+        } else if (lua_key_eq(s, script)) {
             fast_metatable_or_nil(script_mlist(n));
-        } else if (luaS_ptr_eq(s, scriptscript)) {
+        } else if (lua_key_eq(s, scriptscript)) {
             fast_metatable_or_nil(script_script_mlist(n));
         } else {
             lua_pushnil(L);
         }
     } else if (t == inserting_node) {
-        if (luaS_ptr_eq(s, subtype)) {
+        if (lua_key_eq(s, subtype)) {
             lua_pushnumber(L, subtype(n));
-        } else if (luaS_ptr_eq(s, last_ins_ptr)) {
+        } else if (lua_key_eq(s, last_ins_ptr)) {
             fast_metatable_or_nil(last_ins_ptr(n));
-        } else if (luaS_ptr_eq(s, best_ins_ptr)) {
+        } else if (lua_key_eq(s, best_ins_ptr)) {
             fast_metatable_or_nil(best_ins_ptr(n));
         } else {
             lua_pushnil(L);
         }
     } else if (t == attribute_node) {
-        if (luaS_ptr_eq(s, subtype)) {
+        if (lua_key_eq(s, subtype)) {
             lua_pushnumber(L, subtype(n));
-        } else if (luaS_ptr_eq(s, number)) {
+        } else if (lua_key_eq(s, number)) {
             lua_pushnumber(L, attribute_id(n));
-        } else if (luaS_ptr_eq(s, value)) {
+        } else if (lua_key_eq(s, value)) {
             lua_pushnumber(L, attribute_value(n));
         } else {
             lua_pushnil(L);
         }
     } else if (t == adjust_node) {
-        if (luaS_ptr_eq(s, subtype)) {
+        if (lua_key_eq(s, subtype)) {
             lua_pushnumber(L, subtype(n));
-        } else if ((luaS_ptr_eq(s, list)) || (luaS_ptr_eq(s, head))) {
+        } else if ((lua_key_eq(s, list)) || (lua_key_eq(s, head))) {
             fast_metatable_or_nil_alink(adjust_ptr(n));
         } else {
             lua_pushnil(L);
         }
     } else if (t == action_node) {
-        if (luaS_ptr_eq(s, subtype)) {
+        if (lua_key_eq(s, subtype)) {
             lua_pushnumber(L, subtype(n));/* dummy subtype */
-        } else if (luaS_ptr_eq(s, action_type)) {
+        } else if (lua_key_eq(s, action_type)) {
             lua_pushnumber(L, pdf_action_type(n));
-        } else if (luaS_ptr_eq(s, named_id)) {
+        } else if (lua_key_eq(s, named_id)) {
             lua_pushnumber(L, pdf_action_named_id(n));
-        } else if (luaS_ptr_eq(s, action_id)) {
+        } else if (lua_key_eq(s, action_id)) {
             if (pdf_action_named_id(n) == 1) {
                 tokenlist_to_luastring(L, pdf_action_id(n));
             } else {
                 lua_pushnumber(L, pdf_action_id(n));
             }
-        } else if (luaS_ptr_eq(s, file)) {
+        } else if (lua_key_eq(s, file)) {
             tokenlist_to_luastring(L, pdf_action_file(n));
-        } else if (luaS_ptr_eq(s, new_window)) {
+        } else if (lua_key_eq(s, new_window)) {
             lua_pushnumber(L, pdf_action_new_window(n));
-        } else if (luaS_ptr_eq(s, data)) {
+        } else if (lua_key_eq(s, data)) {
             tokenlist_to_luastring(L, pdf_action_tokens(n));
-        } else if (luaS_ptr_eq(s, ref_count)) {
+        } else if (lua_key_eq(s, ref_count)) {
             lua_pushnumber(L, pdf_action_refcount(n));
         } else {
             lua_pushnil(L);
         }
     } else if (t == unset_node) {
-        if (luaS_ptr_eq(s, subtype)) {
+        if (lua_key_eq(s, subtype)) {
             lua_pushnumber(L, subtype(n));
-        } else if (luaS_ptr_eq(s, width)) {
+        } else if (lua_key_eq(s, width)) {
             lua_pushnumber(L, width(n));
-        } else if (luaS_ptr_eq(s, height)) {
+        } else if (lua_key_eq(s, height)) {
             lua_pushnumber(L, height(n));
-        } else if (luaS_ptr_eq(s, depth)) {
+        } else if (lua_key_eq(s, depth)) {
             lua_pushnumber(L, depth(n));
-        } else if (luaS_ptr_eq(s, dir)) {
+        } else if (lua_key_eq(s, dir)) {
             nodelib_pushdir(L, box_dir(n), false);
-        } else if (luaS_ptr_eq(s, shrink)) {
+        } else if (lua_key_eq(s, shrink)) {
             lua_pushnumber(L, glue_shrink(n));
-        } else if (luaS_ptr_eq(s, glue_order)) {
+        } else if (lua_key_eq(s, glue_order)) {
             lua_pushnumber(L, glue_order(n));
-        } else if (luaS_ptr_eq(s, glue_sign)) {
+        } else if (lua_key_eq(s, glue_sign)) {
             lua_pushnumber(L, glue_sign(n));
-        } else if (luaS_ptr_eq(s, stretch)) {
+        } else if (lua_key_eq(s, stretch)) {
             lua_pushnumber(L, glue_stretch(n));
-        } else if (luaS_ptr_eq(s, count)) {
+        } else if (lua_key_eq(s, count)) {
             lua_pushnumber(L, span_count(n));
-        } else if ((luaS_ptr_eq(s, list)) || (luaS_ptr_eq(s, head))){
+        } else if ((lua_key_eq(s, list)) || (lua_key_eq(s, head))){
             fast_metatable_or_nil_alink(list_ptr(n));
         } else {
             lua_pushnil(L);
         }
     } else if (t == attribute_list_node) {
-        if (luaS_ptr_eq(s, subtype)) {
+        if (lua_key_eq(s, subtype)) {
             lua_pushnumber(L, subtype(n));
         } else {
             lua_pushnil(L);
@@ -3484,23 +3207,23 @@ static void lua_nodelib_direct_getfield_whatsit(lua_State * L, int n, const char
     t = subtype(n);
 
     if (t == dir_node) {
-        if (luaS_ptr_eq(s, dir)) {
+        if (lua_key_eq(s, dir)) {
             nodelib_pushdir(L, dir_dir(n), true);
-        } else if (luaS_ptr_eq(s, level)) {
+        } else if (lua_key_eq(s, level)) {
             lua_pushnumber(L, dir_level(n));
-        } else if (luaS_ptr_eq(s, dvi_ptr)) {
+        } else if (lua_key_eq(s, dvi_ptr)) {
             lua_pushnumber(L, dir_dvi_ptr(n));
-        } else if (luaS_ptr_eq(s, dir_h)) {
+        } else if (lua_key_eq(s, dir_h)) {
             lua_pushnumber(L, dir_dvi_h(n));
         } else {
             lua_pushnil(L);
         }
     } else if (t == user_defined_node) {
-        if (luaS_ptr_eq(s, user_id)) {
+        if (lua_key_eq(s, user_id)) {
             lua_pushnumber(L, user_node_id(n));
-        } else if (luaS_ptr_eq(s, type)) {
+        } else if (lua_key_eq(s, type)) {
             lua_pushnumber(L, user_node_type(n));
-        } else if (luaS_ptr_eq(s, value)) {
+        } else if (lua_key_eq(s, value)) {
             switch (user_node_type(n)) {
             case 'a':
                 nodelib_pushdirect(user_node_value(n));
@@ -3525,27 +3248,27 @@ static void lua_nodelib_direct_getfield_whatsit(lua_State * L, int n, const char
             lua_pushnil(L);
         }
     } else if (t == local_par_node) {
-        if (luaS_ptr_eq(s, pen_inter)) {
+        if (lua_key_eq(s, pen_inter)) {
             lua_pushnumber(L, local_pen_inter(n));
-        } else if (luaS_ptr_eq(s, pen_broken)) {
+        } else if (lua_key_eq(s, pen_broken)) {
             lua_pushnumber(L, local_pen_broken(n));
-        } else if (luaS_ptr_eq(s, dir)) {
+        } else if (lua_key_eq(s, dir)) {
             nodelib_pushdir(L, local_par_dir(n), false);
-        } else if (luaS_ptr_eq(s, box_left)) {
+        } else if (lua_key_eq(s, box_left)) {
             nodelib_pushdirect_or_nil(local_box_left(n));
-        } else if (luaS_ptr_eq(s, box_left_width)) {
+        } else if (lua_key_eq(s, box_left_width)) {
             lua_pushnumber(L, local_box_left_width(n));
-        } else if (luaS_ptr_eq(s, box_right)) {
+        } else if (lua_key_eq(s, box_right)) {
             nodelib_pushdirect_or_nil(local_box_right(n));
-        } else if (luaS_ptr_eq(s, box_right_width)) {
+        } else if (lua_key_eq(s, box_right_width)) {
             lua_pushnumber(L, local_box_right_width(n));
         } else {
             lua_pushnil(L);
         }
     } else if (t == pdf_literal_node) {
-        if (luaS_ptr_eq(s, mode)) {
+        if (lua_key_eq(s, mode)) {
             lua_pushnumber(L, pdf_literal_mode(n));
-        } else if (luaS_ptr_eq(s, data)) {
+        } else if (lua_key_eq(s, data)) {
             if (pdf_literal_type(n) == lua_refid_literal) {
                 lua_rawgeti(Luas, LUA_REGISTRYINDEX, pdf_literal_data(n));
             } else {
@@ -3555,9 +3278,9 @@ static void lua_nodelib_direct_getfield_whatsit(lua_State * L, int n, const char
             lua_pushnil(L);
         }
     } else if (t == late_lua_node) {
-        if (luaS_ptr_eq(s, name)) {
+        if (lua_key_eq(s, name)) {
             tokenlist_to_luastring(L, late_lua_name(n));
-        } else if (luaS_ptr_eq(s, data) || luaS_ptr_eq(s, string)) {
+        } else if (lua_key_eq(s, data) || lua_key_eq(s, string)) {
             if (late_lua_type(n) == lua_refid_literal) {
                 lua_rawgeti(Luas, LUA_REGISTRYINDEX, late_lua_data(n));
             } else {
@@ -3567,154 +3290,154 @@ static void lua_nodelib_direct_getfield_whatsit(lua_State * L, int n, const char
             lua_pushnil(L);
         }
     } else if (t == pdf_annot_node) {
-        if (luaS_ptr_eq(s, width)) {
+        if (lua_key_eq(s, width)) {
             lua_pushnumber(L, width(n));
-        } else if (luaS_ptr_eq(s, depth)) {
+        } else if (lua_key_eq(s, depth)) {
             lua_pushnumber(L, depth(n));
-        } else if (luaS_ptr_eq(s, height)) {
+        } else if (lua_key_eq(s, height)) {
             lua_pushnumber(L, height(n));
-        } else if (luaS_ptr_eq(s, objnum)) {
+        } else if (lua_key_eq(s, objnum)) {
             lua_pushnumber(L, pdf_annot_objnum(n));
-        } else if (luaS_ptr_eq(s, data)) {
+        } else if (lua_key_eq(s, data)) {
             tokenlist_to_luastring(L, pdf_annot_data(n));
         } else {
             lua_pushnil(L);
         }
     } else if (t == pdf_dest_node) {
-        if (luaS_ptr_eq(s, width)) {
+        if (lua_key_eq(s, width)) {
             lua_pushnumber(L, width(n));
-        } else if (luaS_ptr_eq(s, depth)) {
+        } else if (lua_key_eq(s, depth)) {
             lua_pushnumber(L, depth(n));
-        } else if (luaS_ptr_eq(s, height)) {
+        } else if (lua_key_eq(s, height)) {
             lua_pushnumber(L, height(n));
-        } else if (luaS_ptr_eq(s, named_id)) {
+        } else if (lua_key_eq(s, named_id)) {
             lua_pushnumber(L, pdf_dest_named_id(n));
-        } else if (luaS_ptr_eq(s, dest_id)) {
+        } else if (lua_key_eq(s, dest_id)) {
             if (pdf_dest_named_id(n) == 1)
                 tokenlist_to_luastring(L, pdf_dest_id(n));
             else
                 lua_pushnumber(L, pdf_dest_id(n));
-        } else if (luaS_ptr_eq(s, dest_type)) {
+        } else if (lua_key_eq(s, dest_type)) {
             lua_pushnumber(L, pdf_dest_type(n));
-        } else if (luaS_ptr_eq(s, xyz_zoom)) {
+        } else if (lua_key_eq(s, xyz_zoom)) {
             lua_pushnumber(L, pdf_dest_xyz_zoom(n));
-        } else if (luaS_ptr_eq(s, objnum)) {
+        } else if (lua_key_eq(s, objnum)) {
             lua_pushnumber(L, pdf_dest_objnum(n));
         } else {
             lua_pushnil(L);
         }
     } else if (t == pdf_setmatrix_node) {
-        if (luaS_ptr_eq(s, data)) {
+        if (lua_key_eq(s, data)) {
             tokenlist_to_luastring(L, pdf_setmatrix_data(n));
         } else {
             lua_pushnil(L);
         }
     } else if (t == pdf_colorstack_node) {
-        if (luaS_ptr_eq(s, stack)) {
+        if (lua_key_eq(s, stack)) {
             lua_pushnumber(L, pdf_colorstack_stack(n));
-        } else if (luaS_ptr_eq(s, command)) {
+        } else if (lua_key_eq(s, command)) {
             lua_pushnumber(L, pdf_colorstack_cmd(n));
-        } else if (luaS_ptr_eq(s, data)) {
+        } else if (lua_key_eq(s, data)) {
             tokenlist_to_luastring(L, pdf_colorstack_data(n));
         } else {
             lua_pushnil(L);
         }
     } else if (t == pdf_refobj_node) {
-        if (luaS_ptr_eq(s, objnum)) {
+        if (lua_key_eq(s, objnum)) {
             lua_pushnumber(L, pdf_obj_objnum(n));
         } else {
             lua_pushnil(L);
         }
     } else if (t == pdf_refxform_node) {
-        if (luaS_ptr_eq(s, width)) {
+        if (lua_key_eq(s, width)) {
             lua_pushnumber(L, width(n));
-        } else if (luaS_ptr_eq(s, depth)) {
+        } else if (lua_key_eq(s, depth)) {
             lua_pushnumber(L, depth(n));
-        } else if (luaS_ptr_eq(s, height)) {
+        } else if (lua_key_eq(s, height)) {
             lua_pushnumber(L, height(n));
-        } else if (luaS_ptr_eq(s, objnum)) {
+        } else if (lua_key_eq(s, objnum)) {
             lua_pushnumber(L, pdf_xform_objnum(n));
         } else {
             lua_pushnil(L);
         }
     } else if (t == pdf_refximage_node) {
-        if (luaS_ptr_eq(s, width)) {
+        if (lua_key_eq(s, width)) {
             lua_pushnumber(L, width(n));
-        } else if (luaS_ptr_eq(s, depth)) {
+        } else if (lua_key_eq(s, depth)) {
             lua_pushnumber(L, depth(n));
-        } else if (luaS_ptr_eq(s, height)) {
+        } else if (lua_key_eq(s, height)) {
             lua_pushnumber(L, height(n));
-        } else if (luaS_ptr_eq(s, transform)) {
+        } else if (lua_key_eq(s, transform)) {
             lua_pushnumber(L, pdf_ximage_transform(n));
-        } else if (luaS_ptr_eq(s, index)) {
+        } else if (lua_key_eq(s, index)) {
             lua_pushnumber(L, pdf_ximage_index(n));
         } else {
             lua_pushnil(L);
         }
     } else if (t == write_node) {
-        if (luaS_ptr_eq(s, stream)) {
+        if (lua_key_eq(s, stream)) {
             lua_pushnumber(L, write_stream(n));
-        } else if (luaS_ptr_eq(s, data)) {
+        } else if (lua_key_eq(s, data)) {
             tokenlist_to_lua(L, write_tokens(n));
         } else {
             lua_pushnil(L);
         }
     } else if (t == special_node) {
-        if (luaS_ptr_eq(s, data)) {
+        if (lua_key_eq(s, data)) {
             tokenlist_to_luastring(L, write_tokens(n));
         } else {
             lua_pushnil(L);
         }
     } else if (t == pdf_start_link_node) {
-        if (luaS_ptr_eq(s, width)) {
+        if (lua_key_eq(s, width)) {
             lua_pushnumber(L, width(n));
-        } else if (luaS_ptr_eq(s, depth)) {
+        } else if (lua_key_eq(s, depth)) {
             lua_pushnumber(L, depth(n));
-        } else if (luaS_ptr_eq(s, height)) {
+        } else if (lua_key_eq(s, height)) {
             lua_pushnumber(L, height(n));
-        } else if (luaS_ptr_eq(s, objnum)) {
+        } else if (lua_key_eq(s, objnum)) {
             lua_pushnumber(L, pdf_link_objnum(n));
-        } else if (luaS_ptr_eq(s, link_attr)) {
+        } else if (lua_key_eq(s, link_attr)) {
             tokenlist_to_luastring(L, pdf_link_attr(n));
-        } else if (luaS_ptr_eq(s, action)) {
+        } else if (lua_key_eq(s, action)) {
             nodelib_pushaction(L, pdf_link_action(n));
         } else {
             lua_pushnil(L);
         }
     } else if ((t == pdf_thread_node) || (t == pdf_start_thread_node)) {
-        if (luaS_ptr_eq(s, width)) {
+        if (lua_key_eq(s, width)) {
             lua_pushnumber(L, width(n));
-        } else if (luaS_ptr_eq(s, depth)) {
+        } else if (lua_key_eq(s, depth)) {
             lua_pushnumber(L, depth(n));
-        } else if (luaS_ptr_eq(s, height)) {
+        } else if (lua_key_eq(s, height)) {
             lua_pushnumber(L, height(n));
-        } else if (luaS_ptr_eq(s, named_id)) {
+        } else if (lua_key_eq(s, named_id)) {
             lua_pushnumber(L, pdf_thread_named_id(n));
-        } else if (luaS_ptr_eq(s, thread_id)) {
+        } else if (lua_key_eq(s, thread_id)) {
             if (pdf_thread_named_id(n) == 1) {
                 tokenlist_to_luastring(L, pdf_thread_id(n));
             } else {
                 lua_pushnumber(L, pdf_thread_id(n));
             }
-        } else if (luaS_ptr_eq(s, thread_attr)) {
+        } else if (lua_key_eq(s, thread_attr)) {
             tokenlist_to_luastring(L, pdf_thread_attr(n));
         } else {
             lua_pushnil(L);
         }
     } else if (t == open_node) {
-        if (luaS_ptr_eq(s, stream)) {
+        if (lua_key_eq(s, stream)) {
             lua_pushnumber(L, write_stream(n));
-        } else if (luaS_ptr_eq(s, name)) {
+        } else if (lua_key_eq(s, name)) {
             nodelib_pushstring(L, open_name(n));
-        } else if (luaS_ptr_eq(s, area)) {
+        } else if (lua_key_eq(s, area)) {
             nodelib_pushstring(L, open_area(n));
-        } else if (luaS_ptr_eq(s, ext)) {
+        } else if (lua_key_eq(s, ext)) {
             nodelib_pushstring(L, open_ext(n));
         } else {
             lua_pushnil(L);
         }
     } else if (t == close_node) {
-        if (luaS_ptr_eq(s, stream)) {
+        if (lua_key_eq(s, stream)) {
             lua_pushnumber(L, write_stream(n));
         } else {
             lua_pushnil(L);
@@ -3768,136 +3491,136 @@ static int lua_nodelib_direct_getfield(lua_State * L)
 
     s = lua_tostring(L, 2);
 
-    if (luaS_ptr_eq(s, id)) {
+    if (lua_key_eq(s, id)) {
         lua_pushnumber(L, t);
-    } else if (luaS_ptr_eq(s, next)) {
+    } else if (lua_key_eq(s, next)) {
         nodelib_pushdirect_or_nil(vlink(n));
-    } else if (luaS_ptr_eq(s, prev)) {
+    } else if (lua_key_eq(s, prev)) {
         nodelib_pushdirect_or_nil(alink(n));
-    } else if (luaS_ptr_eq(s, attr)) {
+    } else if (lua_key_eq(s, attr)) {
         if (! nodetype_has_attributes(t)) {
             lua_pushnil(L);
         } else {
             nodelib_pushattr(L, node_attr(n));
         }
-    } else if (luaS_ptr_eq(s, subtype)) {
+    } else if (lua_key_eq(s, subtype)) {
         if (t == glue_spec_node) {
             lua_pushnumber(L, 0); /* dummy, the only one */
         } else {
             lua_pushnumber(L, subtype(n));
         }
     } else if (t == glyph_node) {
-        if (luaS_ptr_eq(s, font)) {
+        if (lua_key_eq(s, font)) {
             lua_pushnumber(L, font(n));
-        } else if (luaS_ptr_eq(s, char)) {
+        } else if (lua_key_eq(s, char)) {
             lua_pushnumber(L, character(n));
-        } else if (luaS_ptr_eq(s, xoffset)) {
+        } else if (lua_key_eq(s, xoffset)) {
             lua_pushnumber(L, x_displace(n));
-        } else if (luaS_ptr_eq(s, yoffset)) {
+        } else if (lua_key_eq(s, yoffset)) {
             lua_pushnumber(L, y_displace(n));
-        } else if (luaS_ptr_eq(s, width)) {
+        } else if (lua_key_eq(s, width)) {
             lua_pushnumber(L, char_width(font(n),character(n)));
-        } else if (luaS_ptr_eq(s, height)) {
+        } else if (lua_key_eq(s, height)) {
             lua_pushnumber(L, char_height(font(n),character(n)));
-        } else if (luaS_ptr_eq(s, depth)) {
+        } else if (lua_key_eq(s, depth)) {
             lua_pushnumber(L, char_depth(font(n),character(n)));
-        } else if (luaS_ptr_eq(s, expansion_factor)) {
+        } else if (lua_key_eq(s, expansion_factor)) {
             lua_pushnumber(L, ex_glyph(n));
-        } else if (luaS_ptr_eq(s, components)) {
+        } else if (lua_key_eq(s, components)) {
             nodelib_pushdirect_or_nil(lig_ptr(n));
-        } else if (luaS_ptr_eq(s, lang)) {
+        } else if (lua_key_eq(s, lang)) {
             lua_pushnumber(L, char_lang(n));
-        } else if (luaS_ptr_eq(s, left)) {
+        } else if (lua_key_eq(s, left)) {
             lua_pushnumber(L, char_lhmin(n));
-        } else if (luaS_ptr_eq(s, right)) {
+        } else if (lua_key_eq(s, right)) {
             lua_pushnumber(L, char_rhmin(n));
-        } else if (luaS_ptr_eq(s, uchyph)) {
+        } else if (lua_key_eq(s, uchyph)) {
             lua_pushnumber(L, char_uchyph(n));
         } else {
             lua_pushnil(L);
         }
     } else if ((t == hlist_node) || (t == vlist_node)) {
         /* candidates: whd (width,height,depth) */
-        if (luaS_ptr_eq(s, list) || luaS_ptr_eq(s, head)) {
+        if (lua_key_eq(s, list) || lua_key_eq(s, head)) {
             nodelib_pushdirect_or_nil_alink(list_ptr(n));
-        } else if (luaS_ptr_eq(s, width)) {
+        } else if (lua_key_eq(s, width)) {
             lua_pushnumber(L, width(n));
-        } else if (luaS_ptr_eq(s, height)) {
+        } else if (lua_key_eq(s, height)) {
             lua_pushnumber(L, height(n));
-        } else if (luaS_ptr_eq(s, depth)) {
+        } else if (lua_key_eq(s, depth)) {
             lua_pushnumber(L, depth(n));
-        } else if (luaS_ptr_eq(s, dir)) {
+        } else if (lua_key_eq(s, dir)) {
             nodelib_pushdir(L, box_dir(n), false);
-        } else if (luaS_ptr_eq(s, shift)) {
+        } else if (lua_key_eq(s, shift)) {
             lua_pushnumber(L, shift_amount(n));
-        } else if (luaS_ptr_eq(s, glue_order)) {
+        } else if (lua_key_eq(s, glue_order)) {
             lua_pushnumber(L, glue_order(n));
-        } else if (luaS_ptr_eq(s, glue_sign)) {
+        } else if (lua_key_eq(s, glue_sign)) {
             lua_pushnumber(L, glue_sign(n));
-        } else if (luaS_ptr_eq(s, glue_set)) {
+        } else if (lua_key_eq(s, glue_set)) {
             lua_pushnumber(L, (double) glue_set(n));
         } else {
             lua_pushnil(L);
         }
     } else if (t == disc_node) {
-        if (luaS_ptr_eq(s, pre)) {
+        if (lua_key_eq(s, pre)) {
             nodelib_pushdirect_or_nil(vlink(pre_break(n)));
-        } else if (luaS_ptr_eq(s, post)) {
+        } else if (lua_key_eq(s, post)) {
             nodelib_pushdirect_or_nil(vlink(post_break(n)));
-        } else if (luaS_ptr_eq(s, replace)) {
+        } else if (lua_key_eq(s, replace)) {
             nodelib_pushdirect_or_nil(vlink(no_break(n)));
         } else {
             lua_pushnil(L);
         }
     } else if (t == glue_node) {
-        if (luaS_ptr_eq(s, spec)) {
+        if (lua_key_eq(s, spec)) {
             nodelib_pushdirect(glue_ptr(n));
-        } else if (luaS_ptr_eq(s, leader)) {
+        } else if (lua_key_eq(s, leader)) {
             nodelib_pushdirect_or_nil(leader_ptr(n));
         } else {
             lua_pushnil(L);
         }
     } else if (t == glue_spec_node) {
-        if (luaS_ptr_eq(s, width)) {
+        if (lua_key_eq(s, width)) {
             lua_pushnumber(L, width(n));
-        } else if (luaS_ptr_eq(s, stretch)) {
+        } else if (lua_key_eq(s, stretch)) {
             lua_pushnumber(L, stretch(n));
-        } else if (luaS_ptr_eq(s, shrink)) {
+        } else if (lua_key_eq(s, shrink)) {
             lua_pushnumber(L, shrink(n));
-        } else if (luaS_ptr_eq(s, stretch_order)) {
+        } else if (lua_key_eq(s, stretch_order)) {
             lua_pushnumber(L, stretch_order(n));
-        } else if (luaS_ptr_eq(s, shrink_order)) {
+        } else if (lua_key_eq(s, shrink_order)) {
             lua_pushnumber(L, shrink_order(n));
-        } else if (luaS_ptr_eq(s, ref_count)) {
+        } else if (lua_key_eq(s, ref_count)) {
             lua_pushnumber(L, glue_ref_count(n));
-        } else if (luaS_ptr_eq(s, writable)) {
+        } else if (lua_key_eq(s, writable)) {
             lua_pushboolean(L, valid_node(n));
         } else {
             lua_pushnil(L);
         }
     } else if (t == kern_node) {
-        if (luaS_ptr_eq(s, kern)) {
+        if (lua_key_eq(s, kern)) {
             lua_pushnumber(L, width(n));
-        } else if (luaS_ptr_eq(s, expansion_factor)) {
+        } else if (lua_key_eq(s, expansion_factor)) {
             lua_pushnumber(L, ex_kern(n));
         } else {
             lua_pushnil(L);
         }
     } else if (t == penalty_node) {
-        if (luaS_ptr_eq(s, penalty)) {
+        if (lua_key_eq(s, penalty)) {
             lua_pushnumber(L, penalty(n));
         } else {
             lua_pushnil(L);
         }
     } else if (t == rule_node) {
         /* candidates: whd (width,height,depth) */
-        if (luaS_ptr_eq(s, width)) {
+        if (lua_key_eq(s, width)) {
             lua_pushnumber(L, width(n));
-        } else if (luaS_ptr_eq(s, height)) {
+        } else if (lua_key_eq(s, height)) {
             lua_pushnumber(L, height(n));
-        } else if (luaS_ptr_eq(s, depth)) {
+        } else if (lua_key_eq(s, depth)) {
             lua_pushnumber(L, depth(n));
-        } else if (luaS_ptr_eq(s, dir)) {
+        } else if (lua_key_eq(s, dir)) {
             nodelib_pushdir(L, rule_dir(n), false);
         } else {
             lua_pushnil(L);
@@ -3905,219 +3628,219 @@ static int lua_nodelib_direct_getfield(lua_State * L)
     } else if (t == whatsit_node) {
         lua_nodelib_direct_getfield_whatsit(L, n, s);
     } else if (t == simple_noad) {
-        if (luaS_ptr_eq(s, nucleus)) {
+        if (lua_key_eq(s, nucleus)) {
             nodelib_pushdirect_or_nil(nucleus(n));
-        } else if (luaS_ptr_eq(s, sub)) {
+        } else if (lua_key_eq(s, sub)) {
             nodelib_pushdirect_or_nil(subscr(n));
-        } else if (luaS_ptr_eq(s, sup)) {
+        } else if (lua_key_eq(s, sup)) {
             nodelib_pushdirect_or_nil(supscr(n));
         } else {
             lua_pushnil(L);
         }
     } else if ((t == math_char_node) || (t == math_text_char_node)) {
-        if (luaS_ptr_eq(s, fam)) {
+        if (lua_key_eq(s, fam)) {
             lua_pushnumber(L, math_fam(n));
-        } else if (luaS_ptr_eq(s, char)) {
+        } else if (lua_key_eq(s, char)) {
             lua_pushnumber(L, math_character(n));
         } else {
             lua_pushnil(L);
         }
     } else if (t == mark_node) {
-        if (luaS_ptr_eq(s, class)) {
+        if (lua_key_eq(s, class)) {
             lua_pushnumber(L, mark_class(n));
-        } else if (luaS_ptr_eq(s, mark)) {
+        } else if (lua_key_eq(s, mark)) {
             tokenlist_to_lua(L, mark_ptr(n));
         } else {
             lua_pushnil(L);
         }
     } else if (t == ins_node) {
-        if (luaS_ptr_eq(s, cost)) {
+        if (lua_key_eq(s, cost)) {
             lua_pushnumber(L, float_cost(n));
-        } else if (luaS_ptr_eq(s, depth)) {
+        } else if (lua_key_eq(s, depth)) {
             lua_pushnumber(L, depth(n));
-        } else if (luaS_ptr_eq(s, height)) {
+        } else if (lua_key_eq(s, height)) {
             lua_pushnumber(L, height(n));
-        } else if (luaS_ptr_eq(s, spec)) {
+        } else if (lua_key_eq(s, spec)) {
             nodelib_pushdirect_or_nil(split_top_ptr(n));
-        } else if ((luaS_ptr_eq(s, list)) || (luaS_ptr_eq(s, head))) {
+        } else if ((lua_key_eq(s, list)) || (lua_key_eq(s, head))) {
             nodelib_pushdirect_or_nil_alink(ins_ptr(n));
         } else {
             lua_pushnil(L);
         }
     } else if (t == math_node) {
-        if (luaS_ptr_eq(s, surround)) {
+        if (lua_key_eq(s, surround)) {
             lua_pushnumber(L, surround(n));
         } else {
             lua_pushnil(L);
         }
     } else if (t == fraction_noad) {
-        if (luaS_ptr_eq(s, width)) {
+        if (lua_key_eq(s, width)) {
             lua_pushnumber(L, thickness(n));
-        } else if (luaS_ptr_eq(s, num)) {
+        } else if (lua_key_eq(s, num)) {
             nodelib_pushdirect_or_nil(numerator(n));
-        } else if (luaS_ptr_eq(s, denom)) {
+        } else if (lua_key_eq(s, denom)) {
             nodelib_pushdirect_or_nil(denominator(n));
-        } else if (luaS_ptr_eq(s, left)) {
+        } else if (lua_key_eq(s, left)) {
             nodelib_pushdirect_or_nil(left_delimiter(n));
-        } else if (luaS_ptr_eq(s, right)) {
+        } else if (lua_key_eq(s, right)) {
             nodelib_pushdirect_or_nil(right_delimiter(n));
         } else {
             lua_pushnil(L);
         }
     } else if (t == style_node) {
-        if (luaS_ptr_eq(s, style)) {
+        if (lua_key_eq(s, style)) {
             lua_pushstring(L, math_style_names[subtype(n)]);
         } else {
             lua_pushnil(L);
         }
     } else if (t == accent_noad) {
-        if (luaS_ptr_eq(s, nucleus)) {
+        if (lua_key_eq(s, nucleus)) {
             nodelib_pushdirect_or_nil(nucleus(n));
-        } else if (luaS_ptr_eq(s, sub)) {
+        } else if (lua_key_eq(s, sub)) {
             nodelib_pushdirect_or_nil(subscr(n));
-        } else if (luaS_ptr_eq(s, sup)) {
+        } else if (lua_key_eq(s, sup)) {
             nodelib_pushdirect_or_nil(supscr(n));
-        } else if (luaS_ptr_eq(s, accent)) {
+        } else if (lua_key_eq(s, accent)) {
             nodelib_pushdirect_or_nil(accent_chr(n));
-        } else if (luaS_ptr_eq(s, bot_accent)) {
+        } else if (lua_key_eq(s, bot_accent)) {
             nodelib_pushdirect_or_nil(bot_accent_chr(n));
         } else {
             lua_pushnil(L);
         }
     } else if (t == fence_noad) {
-        if (luaS_ptr_eq(s, delim)) {
+        if (lua_key_eq(s, delim)) {
             nodelib_pushdirect_or_nil(delimiter(n));
         } else {
             lua_pushnil(L);
         }
     } else if (t == delim_node) {
-        if (luaS_ptr_eq(s, small_fam)) {
+        if (lua_key_eq(s, small_fam)) {
             lua_pushnumber(L, small_fam(n));
-        } else if (luaS_ptr_eq(s, small_char)) {
+        } else if (lua_key_eq(s, small_char)) {
             lua_pushnumber(L, small_char(n));
-        } else if (luaS_ptr_eq(s, large_fam)) {
+        } else if (lua_key_eq(s, large_fam)) {
             lua_pushnumber(L, large_fam(n));
-        } else if (luaS_ptr_eq(s, large_char)) {
+        } else if (lua_key_eq(s, large_char)) {
             lua_pushnumber(L, large_char(n));
         } else {
             lua_pushnil(L);
         }
     } else if ((t == sub_box_node) || (t == sub_mlist_node)) {
-        if ((luaS_ptr_eq(s, list)) || (luaS_ptr_eq(s, head))){
+        if ((lua_key_eq(s, list)) || (lua_key_eq(s, head))){
             nodelib_pushdirect_or_nil_alink(math_list(n));
         } else {
             lua_pushnil(L);
         }
     } else if (t == radical_noad) {
-        if (luaS_ptr_eq(s, nucleus)) {
+        if (lua_key_eq(s, nucleus)) {
             nodelib_pushdirect_or_nil(nucleus(n));
-        } else if (luaS_ptr_eq(s, sub)) {
+        } else if (lua_key_eq(s, sub)) {
             nodelib_pushdirect_or_nil(subscr(n));
-        } else if (luaS_ptr_eq(s, sup)) {
+        } else if (lua_key_eq(s, sup)) {
             nodelib_pushdirect_or_nil(supscr(n));
-        } else if (luaS_ptr_eq(s, left)) {
+        } else if (lua_key_eq(s, left)) {
             nodelib_pushdirect_or_nil(left_delimiter(n));
-        } else if (luaS_ptr_eq(s, degree)) {
+        } else if (lua_key_eq(s, degree)) {
             nodelib_pushdirect_or_nil(degree(n));
         } else {
             lua_pushnil(L);
         }
     } else if (t == margin_kern_node) {
-        if (luaS_ptr_eq(s, width)) {
+        if (lua_key_eq(s, width)) {
             lua_pushnumber(L, width(n));
-        } else if (luaS_ptr_eq(s, glyph)) {
+        } else if (lua_key_eq(s, glyph)) {
             nodelib_pushdirect_or_nil(margin_char(n));
         } else {
             lua_pushnil(L);
         }
     } else if (t == split_up_node) {
-        if (luaS_ptr_eq(s, last_ins_ptr)) {
+        if (lua_key_eq(s, last_ins_ptr)) {
             nodelib_pushdirect_or_nil(last_ins_ptr(n));
-        } else if (luaS_ptr_eq(s, best_ins_ptr)) {
+        } else if (lua_key_eq(s, best_ins_ptr)) {
             nodelib_pushdirect_or_nil(best_ins_ptr(n));
-        } else if (luaS_ptr_eq(s, broken_ptr)) {
+        } else if (lua_key_eq(s, broken_ptr)) {
             nodelib_pushdirect_or_nil(broken_ptr(n));
-        } else if (luaS_ptr_eq(s, broken_ins)) {
+        } else if (lua_key_eq(s, broken_ins)) {
             nodelib_pushdirect_or_nil(broken_ins(n));
         } else {
             lua_pushnil(L);
         }
     } else if (t == choice_node) {
-        if (luaS_ptr_eq(s, display)) {
+        if (lua_key_eq(s, display)) {
             nodelib_pushdirect_or_nil(display_mlist(n));
-        } else if (luaS_ptr_eq(s, text)) {
+        } else if (lua_key_eq(s, text)) {
             nodelib_pushdirect_or_nil(text_mlist(n));
-        } else if (luaS_ptr_eq(s, script)) {
+        } else if (lua_key_eq(s, script)) {
             nodelib_pushdirect_or_nil(script_mlist(n));
-        } else if (luaS_ptr_eq(s, scriptscript)) {
+        } else if (lua_key_eq(s, scriptscript)) {
             nodelib_pushdirect_or_nil(script_script_mlist(n));
         } else {
             lua_pushnil(L);
         }
     } else if (t == inserting_node) {
-        if (luaS_ptr_eq(s, last_ins_ptr)) {
+        if (lua_key_eq(s, last_ins_ptr)) {
             nodelib_pushdirect_or_nil(last_ins_ptr(n));
-        } else if (luaS_ptr_eq(s, best_ins_ptr)) {
+        } else if (lua_key_eq(s, best_ins_ptr)) {
             nodelib_pushdirect_or_nil(best_ins_ptr(n));
         } else {
             lua_pushnil(L);
         }
     } else if (t == attribute_node) {
-        if (luaS_ptr_eq(s, number)) {
+        if (lua_key_eq(s, number)) {
             lua_pushnumber(L, attribute_id(n));
-        } else if (luaS_ptr_eq(s, value)) {
+        } else if (lua_key_eq(s, value)) {
             lua_pushnumber(L, attribute_value(n));
         } else {
             lua_pushnil(L);
         }
     } else if (t == adjust_node) {
-        if ((luaS_ptr_eq(s, list)) || (luaS_ptr_eq(s, head))) {
+        if ((lua_key_eq(s, list)) || (lua_key_eq(s, head))) {
             nodelib_pushdirect_or_nil_alink(adjust_ptr(n));
         } else {
             lua_pushnil(L);
         }
     } else if (t == action_node) {
-        if (luaS_ptr_eq(s, action_type)) {
+        if (lua_key_eq(s, action_type)) {
             lua_pushnumber(L, pdf_action_type(n));
-        } else if (luaS_ptr_eq(s, named_id)) {
+        } else if (lua_key_eq(s, named_id)) {
             lua_pushnumber(L, pdf_action_named_id(n));
-        } else if (luaS_ptr_eq(s, action_id)) {
+        } else if (lua_key_eq(s, action_id)) {
             if (pdf_action_named_id(n) == 1) {
                 tokenlist_to_luastring(L, pdf_action_id(n));
             } else {
                 lua_pushnumber(L, pdf_action_id(n));
             }
-        } else if (luaS_ptr_eq(s, file)) {
+        } else if (lua_key_eq(s, file)) {
             tokenlist_to_luastring(L, pdf_action_file(n));
-        } else if (luaS_ptr_eq(s, new_window)) {
+        } else if (lua_key_eq(s, new_window)) {
             lua_pushnumber(L, pdf_action_new_window(n));
-        } else if (luaS_ptr_eq(s, data)) {
+        } else if (lua_key_eq(s, data)) {
             tokenlist_to_luastring(L, pdf_action_tokens(n));
-        } else if (luaS_ptr_eq(s, ref_count)) {
+        } else if (lua_key_eq(s, ref_count)) {
             lua_pushnumber(L, pdf_action_refcount(n));
         } else {
             lua_pushnil(L);
         }
     } else if (t == unset_node) {
-        if (luaS_ptr_eq(s, width)) {
+        if (lua_key_eq(s, width)) {
             lua_pushnumber(L, width(n));
-        } else if (luaS_ptr_eq(s, height)) {
+        } else if (lua_key_eq(s, height)) {
             lua_pushnumber(L, height(n));
-        } else if (luaS_ptr_eq(s, depth)) {
+        } else if (lua_key_eq(s, depth)) {
             lua_pushnumber(L, depth(n));
-        } else if (luaS_ptr_eq(s, dir)) {
+        } else if (lua_key_eq(s, dir)) {
             nodelib_pushdir(L, box_dir(n), false);
-        } else if (luaS_ptr_eq(s, shrink)) {
+        } else if (lua_key_eq(s, shrink)) {
             lua_pushnumber(L, glue_shrink(n));
-        } else if (luaS_ptr_eq(s, glue_order)) {
+        } else if (lua_key_eq(s, glue_order)) {
             lua_pushnumber(L, glue_order(n));
-        } else if (luaS_ptr_eq(s, glue_sign)) {
+        } else if (lua_key_eq(s, glue_sign)) {
             lua_pushnumber(L, glue_sign(n));
-        } else if (luaS_ptr_eq(s, stretch)) {
+        } else if (lua_key_eq(s, stretch)) {
             lua_pushnumber(L, glue_stretch(n));
-        } else if (luaS_ptr_eq(s, count)) {
+        } else if (lua_key_eq(s, count)) {
             lua_pushnumber(L, span_count(n));
-        } else if ((luaS_ptr_eq(s, list)) || (luaS_ptr_eq(s, head))){
+        } else if ((lua_key_eq(s, list)) || (lua_key_eq(s, head))){
             nodelib_pushdirect_or_nil_alink(list_ptr(n));
         } else {
             lua_pushnil(L);
@@ -4444,7 +4167,7 @@ static int lua_nodelib_direct_has_glyph(lua_State * L)
 
 static int lua_nodelib_first_character(lua_State * L)
 {
-    pdftex_warn("node.first_character() is deprecated, please update to node.first_glyph()");
+    luatex_warn("node.first_character() is deprecated, please update to node.first_glyph()");
     return lua_nodelib_first_glyph(L);
 }
 
@@ -4569,7 +4292,7 @@ static int lua_nodelib_currentattr(lua_State * L)
         return 1;
     } else {
         /* assign */
-        pdftex_warn("Assignment via node.current_attr(<list>) is not supported (yet)");
+        luatex_warn("Assignment via node.current_attr(<list>) is not supported (yet)");
         return 0;
     }
 }
@@ -4600,7 +4323,7 @@ static int lua_nodelib_direct_todirect(lua_State * L)
 {
     if (lua_type(L,1) != LUA_TNUMBER) {
         /* assume node, no further testing, used in known situations */
-        void *n ; 
+        void *n ;
         n = lua_touserdata(L, 1);
         if (n == null) {
             lua_pushnil(L);
@@ -4636,21 +4359,21 @@ static int lua_nodelib_setfield_whatsit(lua_State * L, int n, const char *s)
     t = subtype(n);
 
     if (t == dir_node) {
-        if (luaS_ptr_eq(s, dir)) {
+        if (lua_key_eq(s, dir)) {
             dir_dir(n) = nodelib_getdir(L, 3, 0);
-        } else if (luaS_ptr_eq(s, level)) {
+        } else if (lua_key_eq(s, level)) {
             dir_level(n) = (halfword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, dvi_ptr)) {
+        } else if (lua_key_eq(s, dvi_ptr)) {
             dir_dvi_ptr(n) = (halfword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, dir_h)) {
+        } else if (lua_key_eq(s, dir_h)) {
             dir_dvi_h(n) = (halfword) lua_tointeger(L, 3);
         } else {
             return nodelib_cantset(L, n, s);
         }
     } else if (t == pdf_literal_node) {
-        if (luaS_ptr_eq(s, mode)) {
+        if (lua_key_eq(s, mode)) {
             pdf_literal_mode(n) = (quarterword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, data)) {
+        } else if (lua_key_eq(s, data)) {
             if (ini_version) {
                 pdf_literal_data(n) = nodelib_gettoks(L, 3);
             } else {
@@ -4662,12 +4385,12 @@ static int lua_nodelib_setfield_whatsit(lua_State * L, int n, const char *s)
             return nodelib_cantset(L, n, s);
         }
     } else if (t == late_lua_node) {
-        if (luaS_ptr_eq(s, data)) {
+        if (lua_key_eq(s, data)) {
             late_lua_data(n) = nodelib_gettoks(L, 3);
             late_lua_type(n) = normal;
-        } else if (luaS_ptr_eq(s, name)) {
+        } else if (lua_key_eq(s, name)) {
             late_lua_name(n) = nodelib_gettoks(L, 3);
-        } else if (luaS_ptr_eq(s, string)) {
+        } else if (lua_key_eq(s, string)) {
             if (ini_version) {
                 late_lua_data(n) = nodelib_gettoks(L, 3);
                 late_lua_type(n) = normal;
@@ -4680,11 +4403,11 @@ static int lua_nodelib_setfield_whatsit(lua_State * L, int n, const char *s)
             return nodelib_cantset(L, n, s);
         }
     } else if (t == user_defined_node) {
-        if (luaS_ptr_eq(s, user_id)) {
+        if (lua_key_eq(s, user_id)) {
             user_node_id(n) = (halfword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, type)) {
+        } else if (lua_key_eq(s, type)) {
             user_node_type(n) = (halfword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, value)) {
+        } else if (lua_key_eq(s, value)) {
             switch (user_node_type(n)) {
             case 'a':
                 user_node_value(n) = nodelib_getlist(L, 3);
@@ -4709,173 +4432,173 @@ static int lua_nodelib_setfield_whatsit(lua_State * L, int n, const char *s)
             return nodelib_cantset(L, n, s);
         }
     } else if (t == pdf_annot_node) {
-        if (luaS_ptr_eq(s, width)) {
+        if (lua_key_eq(s, width)) {
             width(n) = (halfword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, depth)) {
+        } else if (lua_key_eq(s, depth)) {
             depth(n) = (halfword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, height)) {
+        } else if (lua_key_eq(s, height)) {
             height(n) = (halfword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, objnum)) {
+        } else if (lua_key_eq(s, objnum)) {
             pdf_annot_objnum(n) = (halfword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, data)) {
+        } else if (lua_key_eq(s, data)) {
             pdf_annot_data(n) = nodelib_gettoks(L, 3);
         } else {
             return nodelib_cantset(L, n, s);
         }
     } else if (t == pdf_dest_node) {
-        if (luaS_ptr_eq(s, width)) {
+        if (lua_key_eq(s, width)) {
             width(n) = (halfword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, depth)) {
+        } else if (lua_key_eq(s, depth)) {
             depth(n) = (halfword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, height)) {
+        } else if (lua_key_eq(s, height)) {
             height(n) = (halfword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, named_id)) {
+        } else if (lua_key_eq(s, named_id)) {
             pdf_dest_named_id(n) = (quarterword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, dest_id)) {
+        } else if (lua_key_eq(s, dest_id)) {
             if (pdf_dest_named_id(n) == 1) {
                 pdf_dest_id(n) = nodelib_gettoks(L, 3);
             } else {
                 pdf_dest_id(n) = (halfword) lua_tointeger(L, 3);
             }
-        } else if (luaS_ptr_eq(s, dest_type)) {
+        } else if (lua_key_eq(s, dest_type)) {
             pdf_dest_type(n) = (quarterword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, xyz_zoom)) {
+        } else if (lua_key_eq(s, xyz_zoom)) {
             pdf_dest_xyz_zoom(n) = (halfword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, objnum)) {
+        } else if (lua_key_eq(s, objnum)) {
             pdf_dest_objnum(n) = (halfword) lua_tointeger(L, 3);
         } else {
             return nodelib_cantset(L, n, s);
         }
     } else if (t == pdf_setmatrix_node) {
-        if (luaS_ptr_eq(s, data)) {
+        if (lua_key_eq(s, data)) {
             pdf_setmatrix_data(n) = nodelib_gettoks(L, 3);
         } else {
             return nodelib_cantset(L, n, s);
         }
     } else if (t == pdf_refobj_node) {
-        if (luaS_ptr_eq(s, objnum)) {
+        if (lua_key_eq(s, objnum)) {
             pdf_obj_objnum(n) = (halfword) lua_tointeger(L, 3);
         } else {
             return nodelib_cantset(L, n, s);
         }
     } else if (t == pdf_refxform_node) {
-        if (luaS_ptr_eq(s, width)) {
+        if (lua_key_eq(s, width)) {
             width(n) = (halfword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, depth)) {
+        } else if (lua_key_eq(s, depth)) {
             depth(n) = (halfword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, height)) {
+        } else if (lua_key_eq(s, height)) {
             height(n) = (halfword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, objnum)) {
+        } else if (lua_key_eq(s, objnum)) {
             pdf_xform_objnum(n) = (halfword) lua_tointeger(L, 3);
         } else {
             return nodelib_cantset(L, n, s);
         }
     } else if (t == pdf_refximage_node) {
-        if (luaS_ptr_eq(s, width)) {
+        if (lua_key_eq(s, width)) {
             width(n) = (halfword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, depth)) {
+        } else if (lua_key_eq(s, depth)) {
             depth(n) = (halfword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, height)) {
+        } else if (lua_key_eq(s, height)) {
             height(n) = (halfword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, transform)) {
+        } else if (lua_key_eq(s, transform)) {
             pdf_ximage_transform(n) = (halfword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, index)) {
+        } else if (lua_key_eq(s, index)) {
             pdf_ximage_index(n) = (halfword) lua_tointeger(L, 3);
         } else {
             return nodelib_cantset(L, n, s);
         }
     } else if (t == local_par_node) {
-        if (luaS_ptr_eq(s, pen_inter)) {
+        if (lua_key_eq(s, pen_inter)) {
             local_pen_inter(n) = (halfword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, pen_broken)) {
+        } else if (lua_key_eq(s, pen_broken)) {
             local_pen_broken(n) = (halfword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, dir)) {
+        } else if (lua_key_eq(s, dir)) {
             local_par_dir(n) = nodelib_getdir(L, 3, 1);
-        } else if (luaS_ptr_eq(s, box_left)) {
+        } else if (lua_key_eq(s, box_left)) {
             local_box_left(n) = nodelib_getlist(L, 3);
-        } else if (luaS_ptr_eq(s, box_left_width)) {
+        } else if (lua_key_eq(s, box_left_width)) {
             local_box_left_width(n) = (halfword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, box_right)) {
+        } else if (lua_key_eq(s, box_right)) {
             local_box_right(n) = nodelib_getlist(L, 3);
-        } else if (luaS_ptr_eq(s, box_right_width)) {
+        } else if (lua_key_eq(s, box_right_width)) {
             local_box_right_width(n) = (halfword) lua_tointeger(L, 3);
         } else {
             return nodelib_cantset(L, n, s);
         }
     } else if (t == pdf_start_link_node) {
-        if (luaS_ptr_eq(s, width)) {
+        if (lua_key_eq(s, width)) {
             width(n) = (halfword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, depth)) {
+        } else if (lua_key_eq(s, depth)) {
             depth(n) = (halfword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, height)) {
+        } else if (lua_key_eq(s, height)) {
             height(n) = (halfword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, objnum)) {
+        } else if (lua_key_eq(s, objnum)) {
             pdf_link_objnum(n) = (halfword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, link_attr)) {
+        } else if (lua_key_eq(s, link_attr)) {
             pdf_link_attr(n) = nodelib_gettoks(L, 3);
-        } else if (luaS_ptr_eq(s, action)) {
+        } else if (lua_key_eq(s, action)) {
             pdf_link_action(n) = nodelib_getaction(L, 3);
         } else {
             return nodelib_cantset(L, n, s);
         }
     } else if (t == write_node) {
-        if (luaS_ptr_eq(s, stream)) {
+        if (lua_key_eq(s, stream)) {
             write_stream(n) = (halfword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, data)) {
+        } else if (lua_key_eq(s, data)) {
             write_tokens(n) = nodelib_gettoks(L, 3);
         } else {
             return nodelib_cantset(L, n, s);
         }
     } else if (t == pdf_colorstack_node) {
-        if (luaS_ptr_eq(s, stack)) {
+        if (lua_key_eq(s, stack)) {
             pdf_colorstack_stack(n) = (halfword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, command)) {
+        } else if (lua_key_eq(s, command)) {
             pdf_colorstack_cmd(n) = (halfword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, data)) {
+        } else if (lua_key_eq(s, data)) {
             pdf_colorstack_data(n) = nodelib_gettoks(L, 3);
         } else {
             return nodelib_cantset(L, n, s);
         }
     } else if ((t == pdf_thread_node) || (t == pdf_start_thread_node)) {
-        if (luaS_ptr_eq(s, width)) {
+        if (lua_key_eq(s, width)) {
             width(n) = (halfword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, depth)) {
+        } else if (lua_key_eq(s, depth)) {
             depth(n) = (halfword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, height)) {
+        } else if (lua_key_eq(s, height)) {
             height(n) = (halfword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, named_id)) {
+        } else if (lua_key_eq(s, named_id)) {
             pdf_thread_named_id(n) = (quarterword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, thread_id)) {
+        } else if (lua_key_eq(s, thread_id)) {
             if (pdf_thread_named_id(n) == 1) {
                 pdf_thread_id(n) = nodelib_gettoks(L, 3);
             } else {
                 pdf_thread_id(n) = (halfword) lua_tointeger(L, 3);
             }
-        } else if (luaS_ptr_eq(s, thread_attr)) {
+        } else if (lua_key_eq(s, thread_attr)) {
             pdf_thread_attr(n) = nodelib_gettoks(L, 3);
         } else {
             return nodelib_cantset(L, n, s);
         }
     } else if (t == special_node) {
-        if (luaS_ptr_eq(s, data)) {
+        if (lua_key_eq(s, data)) {
             write_tokens(n) = nodelib_gettoks(L, 3);
         } else {
             return nodelib_cantset(L, n, s);
         }
     } else if (t == open_node) {
-        if (luaS_ptr_eq(s, stream)) {
+        if (lua_key_eq(s, stream)) {
             write_stream(n) = (halfword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, name)) {
+        } else if (lua_key_eq(s, name)) {
             open_name(n) = nodelib_getstring(L, 3);
-        } else if (luaS_ptr_eq(s, area)) {
+        } else if (lua_key_eq(s, area)) {
             open_area(n) = nodelib_getstring(L, 3);
-        } else if (luaS_ptr_eq(s, ext)) {
+        } else if (lua_key_eq(s, ext)) {
             open_ext(n) = nodelib_getstring(L, 3);
         } else {
             return nodelib_cantset(L, n, s);
         }
     } else if (t == close_node) {
-        if (luaS_ptr_eq(s, stream)) {
+        if (lua_key_eq(s, stream)) {
             write_stream(n) = (halfword) lua_tointeger(L, 3);
         } else {
             return nodelib_cantset(L, n, s);
@@ -4918,422 +4641,422 @@ static int lua_nodelib_fast_setfield(lua_State * L)
 
     s = lua_tostring(L, 2);
 
-    if (luaS_ptr_eq(s, id)) {
+    if (lua_key_eq(s, id)) {
         lua_pushnumber(L, t);
-    } else if (luaS_ptr_eq(s, next)) {
+    } else if (lua_key_eq(s, next)) {
         halfword x = nodelib_getlist(L, 3);
         if (x>0 && type(x) == glue_spec_node) {
             return luaL_error(L, "You can't assign a %s node to a next field\n", node_data[type(x)].name);
         }
         vlink(n) = x;
-    } else if (luaS_ptr_eq(s, prev)) {
+    } else if (lua_key_eq(s, prev)) {
         halfword x = nodelib_getlist(L, 3);
         if (x>0 && type(x) == glue_spec_node) {
             return luaL_error(L, "You can't assign a %s node to a prev field\n", node_data[type(x)].name);
         }
         alink(n) = x;
-    } else if (luaS_ptr_eq(s, attr)) {
+    } else if (lua_key_eq(s, attr)) {
         if (nodetype_has_attributes(type(n))) {
             nodelib_setattr(L, 3, n);
         }
     } else if (t == glyph_node) {
-        if (luaS_ptr_eq(s, subtype)) {
+        if (lua_key_eq(s, subtype)) {
             subtype(n) = (quarterword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, font)) {
+        } else if (lua_key_eq(s, font)) {
             font(n) = (halfword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, char)) {
+        } else if (lua_key_eq(s, char)) {
             character(n) = (halfword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, xoffset)) {
+        } else if (lua_key_eq(s, xoffset)) {
             x_displace(n) = (halfword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, yoffset)) {
+        } else if (lua_key_eq(s, yoffset)) {
             y_displace(n) = (halfword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, width)) {
+        } else if (lua_key_eq(s, width)) {
             /* not yet */
-        } else if (luaS_ptr_eq(s, height)) {
+        } else if (lua_key_eq(s, height)) {
             /* not yet */
-        } else if (luaS_ptr_eq(s, depth)) {
+        } else if (lua_key_eq(s, depth)) {
             /* not yet */
-        } else if (luaS_ptr_eq(s, expansion_factor)) {
+        } else if (lua_key_eq(s, expansion_factor)) {
             ex_glyph(n) = (halfword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, components)) {
+        } else if (lua_key_eq(s, components)) {
             lig_ptr(n) = nodelib_getlist(L, 3);
-        } else if (luaS_ptr_eq(s, lang)) {
+        } else if (lua_key_eq(s, lang)) {
             set_char_lang(n, (halfword) lua_tointeger(L, 3));
-        } else if (luaS_ptr_eq(s, left)) {
+        } else if (lua_key_eq(s, left)) {
             set_char_lhmin(n, (halfword) lua_tointeger(L, 3));
-        } else if (luaS_ptr_eq(s, right)) {
+        } else if (lua_key_eq(s, right)) {
             set_char_rhmin(n, (halfword) lua_tointeger(L, 3));
-        } else if (luaS_ptr_eq(s, uchyph)) {
+        } else if (lua_key_eq(s, uchyph)) {
             set_char_uchyph(n, (halfword) lua_tointeger(L, 3));
         } else {
             return nodelib_cantset(L, n, s);
         }
     } else if ((t == hlist_node) || (t == vlist_node)) {
-        if (luaS_ptr_eq(s, subtype)) {
+        if (lua_key_eq(s, subtype)) {
             subtype(n) = (quarterword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, list) || luaS_ptr_eq(s, head)) {
+        } else if (lua_key_eq(s, list) || lua_key_eq(s, head)) {
             list_ptr(n) = nodelib_getlist(L, 3);
-        } else if (luaS_ptr_eq(s, width)) {
+        } else if (lua_key_eq(s, width)) {
             width(n) = (halfword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, height)) {
+        } else if (lua_key_eq(s, height)) {
             height(n) = (halfword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, depth)) {
+        } else if (lua_key_eq(s, depth)) {
             depth(n) = (halfword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, dir)) {
+        } else if (lua_key_eq(s, dir)) {
             box_dir(n) = nodelib_getdir(L, 3, 1);
-        } else if (luaS_ptr_eq(s, shift)) {
+        } else if (lua_key_eq(s, shift)) {
             shift_amount(n) = (halfword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, glue_order)) {
+        } else if (lua_key_eq(s, glue_order)) {
             glue_order(n) = (quarterword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, glue_sign)) {
+        } else if (lua_key_eq(s, glue_sign)) {
             glue_sign(n) = (quarterword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, glue_set)) {
+        } else if (lua_key_eq(s, glue_set)) {
             glue_set(n) = (glue_ratio) lua_tonumber(L, 3);
         } else {
             return nodelib_cantset(L, n, s);
         }
     } else if (t == disc_node) {
-        if (luaS_ptr_eq(s, subtype)) {
+        if (lua_key_eq(s, subtype)) {
             subtype(n) = (quarterword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, pre)) {
+        } else if (lua_key_eq(s, pre)) {
             set_disc_field(pre_break(n), nodelib_getlist(L, 3));
-        } else if (luaS_ptr_eq(s, post)) {
+        } else if (lua_key_eq(s, post)) {
             set_disc_field(post_break(n), nodelib_getlist(L, 3));
-        } else if (luaS_ptr_eq(s, replace)) {
+        } else if (lua_key_eq(s, replace)) {
             set_disc_field(no_break(n), nodelib_getlist(L, 3));
         } else {
             return nodelib_cantset(L, n, s);
         }
     } else if (t == glue_node) {
-        if (luaS_ptr_eq(s, subtype)) {
+        if (lua_key_eq(s, subtype)) {
             subtype(n) = (quarterword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, spec)) {
+        } else if (lua_key_eq(s, spec)) {
             glue_ptr(n) = nodelib_getspec(L, 3);
-        } else if (luaS_ptr_eq(s, leader)) {
+        } else if (lua_key_eq(s, leader)) {
             leader_ptr(n) = nodelib_getlist(L, 3);
         } else {
             return nodelib_cantset(L, n, s);
         }
     } else if (t == glue_spec_node) {
-        if (luaS_ptr_eq(s, subtype)) {
+        if (lua_key_eq(s, subtype)) {
             subtype(n) = (quarterword) lua_tointeger(L, 3); /* dummy, the only one that prevents move up */
-        } else if (luaS_ptr_eq(s, width)) {
+        } else if (lua_key_eq(s, width)) {
             width(n) = (halfword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, stretch)) {
+        } else if (lua_key_eq(s, stretch)) {
             stretch(n) = (halfword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, shrink)) {
+        } else if (lua_key_eq(s, shrink)) {
             shrink(n) = (halfword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, stretch_order)) {
+        } else if (lua_key_eq(s, stretch_order)) {
             stretch_order(n) = (quarterword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, shrink_order)) {
+        } else if (lua_key_eq(s, shrink_order)) {
             lua_pushnumber(L, shrink_order(n));
-    /* } else if (luaS_ptr_eq(s, ref_count)) {
+    /* } else if (lua_key_eq(s, ref_count)) {
             glue_ref_count(n) = (halfword) lua_tointeger(L, 3);
-           } else if (luaS_ptr_eq(s, writable)) {
+           } else if (lua_key_eq(s, writable)) {
     */
             /* can't be set */
         } else {
             return nodelib_cantset(L, n, s);
         }
     } else if (t == kern_node) {
-        if (luaS_ptr_eq(s, subtype)) {
+        if (lua_key_eq(s, subtype)) {
             subtype(n) = (quarterword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, kern)) {
+        } else if (lua_key_eq(s, kern)) {
             width(n) = (halfword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, expansion_factor)) {
+        } else if (lua_key_eq(s, expansion_factor)) {
             ex_kern(n) = (halfword) lua_tointeger(L, 3);
         } else {
             return nodelib_cantset(L, n, s);
         }
     } else if (t == penalty_node) {
-        if (luaS_ptr_eq(s, subtype)) {
+        if (lua_key_eq(s, subtype)) {
             /* dummy subtype */
-        } else if (luaS_ptr_eq(s, penalty)) {
+        } else if (lua_key_eq(s, penalty)) {
             penalty(n) = (halfword) lua_tointeger(L, 3);
         } else {
             return nodelib_cantset(L, n, s);
         }
     } else if (t == rule_node) {
-        if (luaS_ptr_eq(s, subtype)) {
+        if (lua_key_eq(s, subtype)) {
             subtype(n) = (quarterword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, width)) {
+        } else if (lua_key_eq(s, width)) {
             width(n) = (halfword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, height)) {
+        } else if (lua_key_eq(s, height)) {
             height(n) = (halfword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, depth)) {
+        } else if (lua_key_eq(s, depth)) {
             depth(n) = (halfword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, dir)) {
+        } else if (lua_key_eq(s, dir)) {
             rule_dir(n) = nodelib_getdir(L, 3, 1);
         } else {
             return nodelib_cantset(L, n, s);
         }
     } else if (t == whatsit_node) {
-        if (luaS_ptr_eq(s, subtype)) {
+        if (lua_key_eq(s, subtype)) {
             subtype(n) = (quarterword) lua_tointeger(L, 3);
         } else {
             lua_nodelib_setfield_whatsit(L, n, s);
         }
     } else if (t == simple_noad) {
-        if (luaS_ptr_eq(s, subtype)) {
+        if (lua_key_eq(s, subtype)) {
             subtype(n) = (quarterword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, nucleus)) {
+        } else if (lua_key_eq(s, nucleus)) {
             nucleus(n) = nodelib_getlist(L, 3);
-        } else if (luaS_ptr_eq(s, sub)) {
+        } else if (lua_key_eq(s, sub)) {
             subscr(n) = nodelib_getlist(L, 3);
-        } else if (luaS_ptr_eq(s, sup)) {
+        } else if (lua_key_eq(s, sup)) {
             supscr(n) = nodelib_getlist(L, 3);
         } else {
             return nodelib_cantset(L, n, s);
         }
     } else if ((t == math_char_node) || (t == math_text_char_node)) {
-        if (luaS_ptr_eq(s, subtype)) {
+        if (lua_key_eq(s, subtype)) {
             subtype(n) = (quarterword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, fam)) {
+        } else if (lua_key_eq(s, fam)) {
             math_fam(n) = (halfword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, char)) {
+        } else if (lua_key_eq(s, char)) {
             math_character(n) = (halfword) lua_tointeger(L, 3);
         } else {
             return nodelib_cantset(L, n, s);
         }
     } else if (t == mark_node) {
-        if (luaS_ptr_eq(s, subtype)) {
+        if (lua_key_eq(s, subtype)) {
             subtype(n) = (quarterword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, class)) {
+        } else if (lua_key_eq(s, class)) {
             mark_class(n) = (halfword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, mark)) {
+        } else if (lua_key_eq(s, mark)) {
             mark_ptr(n) = nodelib_gettoks(L, 3);
         } else {
             return nodelib_cantset(L, n, s);
         }
     } else if (t == ins_node) {
-        if (luaS_ptr_eq(s, subtype)) {
+        if (lua_key_eq(s, subtype)) {
             subtype(n) = (quarterword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, cost)) {
+        } else if (lua_key_eq(s, cost)) {
             float_cost(n) = (halfword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, depth)) {
+        } else if (lua_key_eq(s, depth)) {
             depth(n) = (halfword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, height)) {
+        } else if (lua_key_eq(s, height)) {
             height(n) = (halfword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, spec)) {
+        } else if (lua_key_eq(s, spec)) {
             split_top_ptr(n) = nodelib_getspec(L, 3);
-        } else if ((luaS_ptr_eq(s, list)) || (luaS_ptr_eq(s, head))) {
+        } else if ((lua_key_eq(s, list)) || (lua_key_eq(s, head))) {
             ins_ptr(n) = nodelib_getlist(L, 3);
         } else {
             return nodelib_cantset(L, n, s);
         }
     } else if (t == math_node) {
-        if (luaS_ptr_eq(s, subtype)) {
+        if (lua_key_eq(s, subtype)) {
             subtype(n) = (quarterword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, surround)) {
+        } else if (lua_key_eq(s, surround)) {
             surround(n) = (halfword) lua_tointeger(L, 3);
         } else {
             return nodelib_cantset(L, n, s);
         }
     } else if (t == fraction_noad) {
-        if (luaS_ptr_eq(s, subtype)) {
+        if (lua_key_eq(s, subtype)) {
             subtype(n) = (quarterword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, width)) {
+        } else if (lua_key_eq(s, width)) {
             thickness(n) = (halfword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, num)) {
+        } else if (lua_key_eq(s, num)) {
             numerator(n) = nodelib_getlist(L, 3);
-        } else if (luaS_ptr_eq(s, denom)) {
+        } else if (lua_key_eq(s, denom)) {
             denominator(n) = nodelib_getlist(L, 3);
-        } else if (luaS_ptr_eq(s, left)) {
+        } else if (lua_key_eq(s, left)) {
             left_delimiter(n) = nodelib_getlist(L, 3);
-        } else if (luaS_ptr_eq(s, right)) {
+        } else if (lua_key_eq(s, right)) {
             right_delimiter(n) = nodelib_getlist(L, 3);
         } else {
             return nodelib_cantset(L, n, s);
         }
     } else if (t == style_node) {
-        if (luaS_ptr_eq(s, subtype)) {
+        if (lua_key_eq(s, subtype)) {
             /* dummy subtype */
-        } else if (luaS_ptr_eq(s, style)) {
+        } else if (lua_key_eq(s, style)) {
             lua_pushstring(L, math_style_names[subtype(n)]);
         } else {
             /* return nodelib_cantset(L, n, s); */
             subtype(n) = (quarterword) luaL_checkoption(L, 3, "text", math_style_names); /* not 2? */
         }
     } else if (t == accent_noad) {
-        if (luaS_ptr_eq(s, subtype)) {
+        if (lua_key_eq(s, subtype)) {
             subtype(n) = (quarterword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, nucleus)) {
+        } else if (lua_key_eq(s, nucleus)) {
             nucleus(n) = nodelib_getlist(L, 3);
-        } else if (luaS_ptr_eq(s, sub)) {
+        } else if (lua_key_eq(s, sub)) {
             subscr(n) = nodelib_getlist(L, 3);
-        } else if (luaS_ptr_eq(s, sup)) {
+        } else if (lua_key_eq(s, sup)) {
             supscr(n) = nodelib_getlist(L, 3);
-        } else if (luaS_ptr_eq(s, accent)) {
+        } else if (lua_key_eq(s, accent)) {
             accent_chr(n) = nodelib_getlist(L, 3);
-        } else if (luaS_ptr_eq(s, bot_accent)) {
+        } else if (lua_key_eq(s, bot_accent)) {
             bot_accent_chr(n) = nodelib_getlist(L, 3);
         } else {
             return nodelib_cantset(L, n, s);
         }
     } else if (t == fence_noad) {
-        if (luaS_ptr_eq(s, subtype)) {
+        if (lua_key_eq(s, subtype)) {
             subtype(n) = (quarterword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, delim)) {
+        } else if (lua_key_eq(s, delim)) {
             delimiter(n) = nodelib_getlist(L, 3);
         } else {
             return nodelib_cantset(L, n, s);
         }
     } else if (t == delim_node) {
-        if (luaS_ptr_eq(s, subtype)) {
+        if (lua_key_eq(s, subtype)) {
             subtype(n) = (quarterword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, small_fam)) {
+        } else if (lua_key_eq(s, small_fam)) {
             small_fam(n) = (halfword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, small_char)) {
+        } else if (lua_key_eq(s, small_char)) {
             small_char(n) = (halfword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, large_fam)) {
+        } else if (lua_key_eq(s, large_fam)) {
             large_fam(n) = (halfword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, large_char)) {
+        } else if (lua_key_eq(s, large_char)) {
             large_char(n) = (halfword) lua_tointeger(L, 3);
         } else {
             return nodelib_cantset(L, n, s);
         }
     } else if ((t == sub_box_node) || (t == sub_mlist_node)) {
-        if (luaS_ptr_eq(s, subtype)) {
+        if (lua_key_eq(s, subtype)) {
             subtype(n) = (quarterword) lua_tointeger(L, 3);
-        } else if ((luaS_ptr_eq(s, list)) || (luaS_ptr_eq(s, head))){
+        } else if ((lua_key_eq(s, list)) || (lua_key_eq(s, head))){
             math_list(n) = nodelib_getlist(L, 3);
         } else {
             return nodelib_cantset(L, n, s);
         }
     } else if (t == radical_noad) {
-        if (luaS_ptr_eq(s, subtype)) {
+        if (lua_key_eq(s, subtype)) {
             subtype(n) = (quarterword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, nucleus)) {
+        } else if (lua_key_eq(s, nucleus)) {
             nucleus(n) = nodelib_getlist(L, 3);
-        } else if (luaS_ptr_eq(s, sub)) {
+        } else if (lua_key_eq(s, sub)) {
             subscr(n) = nodelib_getlist(L, 3);
-        } else if (luaS_ptr_eq(s, sup)) {
+        } else if (lua_key_eq(s, sup)) {
             supscr(n) = nodelib_getlist(L, 3);
-        } else if (luaS_ptr_eq(s, left)) {
+        } else if (lua_key_eq(s, left)) {
             left_delimiter(n) = nodelib_getlist(L, 3);
-        } else if (luaS_ptr_eq(s, degree)) {
+        } else if (lua_key_eq(s, degree)) {
             degree(n) = nodelib_getlist(L, 3);
         } else {
             return nodelib_cantset(L, n, s);
         }
     } else if (t == margin_kern_node) {
-        if (luaS_ptr_eq(s, subtype)) {
+        if (lua_key_eq(s, subtype)) {
             subtype(n) = (quarterword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, width)) {
+        } else if (lua_key_eq(s, width)) {
             width(n) = (halfword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, glyph)) {
+        } else if (lua_key_eq(s, glyph)) {
             margin_char(n) = nodelib_getlist(L, 3);
         } else {
             return nodelib_cantset(L, n, s);
         }
     } else if (t == split_up_node) {
-        if (luaS_ptr_eq(s, subtype)) {
+        if (lua_key_eq(s, subtype)) {
             subtype(n) = (quarterword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, last_ins_ptr)) {
+        } else if (lua_key_eq(s, last_ins_ptr)) {
             last_ins_ptr(n) = nodelib_getlist(L, 3);
-        } else if (luaS_ptr_eq(s, best_ins_ptr)) {
+        } else if (lua_key_eq(s, best_ins_ptr)) {
             best_ins_ptr(n) = nodelib_getlist(L, 3);
-        } else if (luaS_ptr_eq(s, broken_ptr)) {
+        } else if (lua_key_eq(s, broken_ptr)) {
             broken_ptr(n) = nodelib_getlist(L, 3);
-        } else if (luaS_ptr_eq(s, broken_ins)) {
+        } else if (lua_key_eq(s, broken_ins)) {
             broken_ins(n) = nodelib_getlist(L, 3);
         } else {
             return nodelib_cantset(L, n, s);
         }
     } else if (t == choice_node) {
-        if (luaS_ptr_eq(s, subtype)) {
+        if (lua_key_eq(s, subtype)) {
             subtype(n) = (quarterword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, display)) {
+        } else if (lua_key_eq(s, display)) {
             display_mlist(n) = nodelib_getlist(L, 3);
-        } else if (luaS_ptr_eq(s, text)) {
+        } else if (lua_key_eq(s, text)) {
             text_mlist(n) = nodelib_getlist(L, 3);
-        } else if (luaS_ptr_eq(s, script)) {
+        } else if (lua_key_eq(s, script)) {
             script_mlist(n) = nodelib_getlist(L, 3);
-        } else if (luaS_ptr_eq(s, scriptscript)) {
+        } else if (lua_key_eq(s, scriptscript)) {
             script_script_mlist(n) = nodelib_getlist(L, 3);
         } else {
             return nodelib_cantset(L, n, s);
         }
     } else if (t == inserting_node) {
-        if (luaS_ptr_eq(s, subtype)) {
+        if (lua_key_eq(s, subtype)) {
             subtype(n) = (quarterword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, last_ins_ptr)) {
+        } else if (lua_key_eq(s, last_ins_ptr)) {
             last_ins_ptr(n) = nodelib_getlist(L, 3);
-        } else if (luaS_ptr_eq(s, best_ins_ptr)) {
+        } else if (lua_key_eq(s, best_ins_ptr)) {
             best_ins_ptr(n) = nodelib_getlist(L, 3);
         } else {
             return nodelib_cantset(L, n, s);
         }
     } else if (t == attribute_node) {
-        if (luaS_ptr_eq(s, subtype)) {
+        if (lua_key_eq(s, subtype)) {
             /* dummy subtype */
-        } else if (luaS_ptr_eq(s, number)) {
+        } else if (lua_key_eq(s, number)) {
             attribute_id(n) = (halfword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, value)) {
+        } else if (lua_key_eq(s, value)) {
             attribute_value(n) = (halfword) lua_tointeger(L, 3);
         } else {
             return nodelib_cantset(L, n, s);
         }
     } else if (t == adjust_node) {
-        if (luaS_ptr_eq(s, subtype)) {
+        if (lua_key_eq(s, subtype)) {
             subtype(n) = (quarterword) lua_tointeger(L, 3);
-        } else if ((luaS_ptr_eq(s, list)) || (luaS_ptr_eq(s, head))) {
+        } else if ((lua_key_eq(s, list)) || (lua_key_eq(s, head))) {
             adjust_ptr(n) = nodelib_getlist(L, 3);
         } else {
             return nodelib_cantset(L, n, s);
         }
     } else if (t == action_node) {
-        if (luaS_ptr_eq(s, subtype)) {
+        if (lua_key_eq(s, subtype)) {
             /* dummy subtype */
-        } else if (luaS_ptr_eq(s, action_type)) {
+        } else if (lua_key_eq(s, action_type)) {
             pdf_action_type(n) = (quarterword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, named_id)) {
+        } else if (lua_key_eq(s, named_id)) {
             pdf_action_named_id(n) = (quarterword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, action_id)) {
+        } else if (lua_key_eq(s, action_id)) {
             if (pdf_action_named_id(n) == 1) {
                 pdf_action_id(n) = nodelib_gettoks(L, 3);
             } else {
                 pdf_action_id(n) = (halfword) lua_tointeger(L, 3);
             }
-        } else if (luaS_ptr_eq(s, file)) {
+        } else if (lua_key_eq(s, file)) {
             pdf_action_file(n) = nodelib_gettoks(L, 3);
-        } else if (luaS_ptr_eq(s, new_window)) {
+        } else if (lua_key_eq(s, new_window)) {
             pdf_action_new_window(n) = (halfword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, data)) {
+        } else if (lua_key_eq(s, data)) {
             pdf_action_tokens(n) = nodelib_gettoks(L, 3);
-        /* } else if (luaS_ptr_eq(s, ref_count)) {
+        /* } else if (lua_key_eq(s, ref_count)) {
             pdf_action_refcount(n) = (halfword) lua_tointeger(L, 3); */
         } else {
             return nodelib_cantset(L, n, s);
         }
     } else if (t == unset_node) {
-        if (luaS_ptr_eq(s, subtype)) {
+        if (lua_key_eq(s, subtype)) {
             /* dummy subtype */
-        } else if (luaS_ptr_eq(s, width)) {
+        } else if (lua_key_eq(s, width)) {
             width(n) = (halfword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, height)) {
+        } else if (lua_key_eq(s, height)) {
             height(n) = (halfword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, depth)) {
+        } else if (lua_key_eq(s, depth)) {
             depth(n) = (halfword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, dir)) {
+        } else if (lua_key_eq(s, dir)) {
             box_dir(n) = nodelib_getdir(L, 3, 1);
-        } else if (luaS_ptr_eq(s, shrink)) {
+        } else if (lua_key_eq(s, shrink)) {
             glue_shrink(n) = (halfword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, glue_order)) {
+        } else if (lua_key_eq(s, glue_order)) {
             glue_order(n) = (quarterword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, glue_sign)) {
+        } else if (lua_key_eq(s, glue_sign)) {
             glue_sign(n) = (quarterword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, stretch)) {
+        } else if (lua_key_eq(s, stretch)) {
             glue_stretch(n) = (halfword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, count)) {
+        } else if (lua_key_eq(s, count)) {
             span_count(n) = (quarterword) lua_tointeger(L, 3);
-        } else if ((luaS_ptr_eq(s, list)) || (luaS_ptr_eq(s, head))){
+        } else if ((lua_key_eq(s, list)) || (lua_key_eq(s, head))){
             list_ptr(n) = nodelib_getlist(L, 3);
         } else {
             return nodelib_cantset(L, n, s);
         }
     } else if (t == attribute_list_node) {
-        if (luaS_ptr_eq(s, subtype)) {
+        if (lua_key_eq(s, subtype)) {
             /* dummy subtype */
         } else {
             return nodelib_cantset(L, n, s);
@@ -5371,21 +5094,21 @@ static int lua_nodelib_direct_setfield_whatsit(lua_State * L, int n, const char
     t = subtype(n);
 
     if (t == dir_node) {
-        if (luaS_ptr_eq(s, dir)) {
+        if (lua_key_eq(s, dir)) {
             dir_dir(n) = nodelib_getdir(L, 3, 0);
-        } else if (luaS_ptr_eq(s, level)) {
+        } else if (lua_key_eq(s, level)) {
             dir_level(n) = (halfword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, dvi_ptr)) {
+        } else if (lua_key_eq(s, dvi_ptr)) {
             dir_dvi_ptr(n) = (halfword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, dir_h)) {
+        } else if (lua_key_eq(s, dir_h)) {
             dir_dvi_h(n) = (halfword) lua_tointeger(L, 3);
         } else {
             return nodelib_cantset(L, n, s);
         }
     } else if (t == pdf_literal_node) {
-        if (luaS_ptr_eq(s, mode)) {
+        if (lua_key_eq(s, mode)) {
             pdf_literal_mode(n) = (quarterword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, data)) {
+        } else if (lua_key_eq(s, data)) {
             if (ini_version) {
                 pdf_literal_data(n) = nodelib_gettoks(L, 3);
             } else {
@@ -5397,12 +5120,12 @@ static int lua_nodelib_direct_setfield_whatsit(lua_State * L, int n, const char
             return nodelib_cantset(L, n, s);
         }
     } else if (t == late_lua_node) {
-        if (luaS_ptr_eq(s, data)) {
+        if (lua_key_eq(s, data)) {
             late_lua_data(n) = nodelib_gettoks(L, 3);
             late_lua_type(n) = normal;
-        } else if (luaS_ptr_eq(s, name)) {
+        } else if (lua_key_eq(s, name)) {
             late_lua_name(n) = nodelib_gettoks(L, 3);
-        } else if (luaS_ptr_eq(s, string)) {
+        } else if (lua_key_eq(s, string)) {
             if (ini_version) {
                 late_lua_data(n) = nodelib_gettoks(L, 3);
                 late_lua_type(n) = normal;
@@ -5415,11 +5138,11 @@ static int lua_nodelib_direct_setfield_whatsit(lua_State * L, int n, const char
             return nodelib_cantset(L, n, s);
         }
     } else if (t == user_defined_node) {
-        if (luaS_ptr_eq(s, user_id)) {
+        if (lua_key_eq(s, user_id)) {
             user_node_id(n) = (halfword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, type)) {
+        } else if (lua_key_eq(s, type)) {
             user_node_type(n) = (halfword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, value)) {
+        } else if (lua_key_eq(s, value)) {
             switch (user_node_type(n)) {
             case 'a':
                 user_node_value(n) = nodelib_getlist(L, 3);
@@ -5444,173 +5167,173 @@ static int lua_nodelib_direct_setfield_whatsit(lua_State * L, int n, const char
             return nodelib_cantset(L, n, s);
         }
     } else if (t == pdf_annot_node) {
-        if (luaS_ptr_eq(s, width)) {
+        if (lua_key_eq(s, width)) {
             width(n) = (halfword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, depth)) {
+        } else if (lua_key_eq(s, depth)) {
             depth(n) = (halfword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, height)) {
+        } else if (lua_key_eq(s, height)) {
             height(n) = (halfword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, objnum)) {
+        } else if (lua_key_eq(s, objnum)) {
             pdf_annot_objnum(n) = (halfword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, data)) {
+        } else if (lua_key_eq(s, data)) {
             pdf_annot_data(n) = nodelib_gettoks(L, 3);
         } else {
             return nodelib_cantset(L, n, s);
         }
     } else if (t == pdf_dest_node) {
-        if (luaS_ptr_eq(s, width)) {
+        if (lua_key_eq(s, width)) {
             width(n) = (halfword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, depth)) {
+        } else if (lua_key_eq(s, depth)) {
             depth(n) = (halfword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, height)) {
+        } else if (lua_key_eq(s, height)) {
             height(n) = (halfword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, named_id)) {
+        } else if (lua_key_eq(s, named_id)) {
             pdf_dest_named_id(n) = (quarterword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, dest_id)) {
+        } else if (lua_key_eq(s, dest_id)) {
             if (pdf_dest_named_id(n) == 1) {
                 pdf_dest_id(n) = nodelib_gettoks(L, 3);
             } else {
                 pdf_dest_id(n) = (halfword) lua_tointeger(L, 3);
             }
-        } else if (luaS_ptr_eq(s, dest_type)) {
+        } else if (lua_key_eq(s, dest_type)) {
             pdf_dest_type(n) = (quarterword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, xyz_zoom)) {
+        } else if (lua_key_eq(s, xyz_zoom)) {
             pdf_dest_xyz_zoom(n) = (halfword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, objnum)) {
+        } else if (lua_key_eq(s, objnum)) {
             pdf_dest_objnum(n) = (halfword) lua_tointeger(L, 3);
         } else {
             return nodelib_cantset(L, n, s);
         }
     } else if (t == pdf_setmatrix_node) {
-        if (luaS_ptr_eq(s, data)) {
+        if (lua_key_eq(s, data)) {
             pdf_setmatrix_data(n) = nodelib_gettoks(L, 3);
         } else {
             return nodelib_cantset(L, n, s);
         }
     } else if (t == pdf_refobj_node) {
-        if (luaS_ptr_eq(s, objnum)) {
+        if (lua_key_eq(s, objnum)) {
             pdf_obj_objnum(n) = (halfword) lua_tointeger(L, 3);
         } else {
             return nodelib_cantset(L, n, s);
         }
     } else if (t == pdf_refxform_node) {
-        if (luaS_ptr_eq(s, width)) {
+        if (lua_key_eq(s, width)) {
             width(n) = (halfword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, depth)) {
+        } else if (lua_key_eq(s, depth)) {
             depth(n) = (halfword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, height)) {
+        } else if (lua_key_eq(s, height)) {
             height(n) = (halfword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, objnum)) {
+        } else if (lua_key_eq(s, objnum)) {
             pdf_xform_objnum(n) = (halfword) lua_tointeger(L, 3);
         } else {
             return nodelib_cantset(L, n, s);
         }
     } else if (t == pdf_refximage_node) {
-        if (luaS_ptr_eq(s, width)) {
+        if (lua_key_eq(s, width)) {
             width(n) = (halfword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, depth)) {
+        } else if (lua_key_eq(s, depth)) {
             depth(n) = (halfword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, height)) {
+        } else if (lua_key_eq(s, height)) {
             height(n) = (halfword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, transform)) {
+        } else if (lua_key_eq(s, transform)) {
             pdf_ximage_transform(n) = (halfword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, index)) {
+        } else if (lua_key_eq(s, index)) {
             pdf_ximage_index(n) = (halfword) lua_tointeger(L, 3);
         } else {
             return nodelib_cantset(L, n, s);
         }
     } else if (t == local_par_node) {
-        if (luaS_ptr_eq(s, pen_inter)) {
+        if (lua_key_eq(s, pen_inter)) {
             local_pen_inter(n) = (halfword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, pen_broken)) {
+        } else if (lua_key_eq(s, pen_broken)) {
             local_pen_broken(n) = (halfword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, dir)) {
+        } else if (lua_key_eq(s, dir)) {
             local_par_dir(n) = nodelib_getdir(L, 3, 1);
-        } else if (luaS_ptr_eq(s, box_left)) {
+        } else if (lua_key_eq(s, box_left)) {
             local_box_left(n) = nodelib_getlist(L, 3);
-        } else if (luaS_ptr_eq(s, box_left_width)) {
+        } else if (lua_key_eq(s, box_left_width)) {
             local_box_left_width(n) = (halfword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, box_right)) {
+        } else if (lua_key_eq(s, box_right)) {
             local_box_right(n) = nodelib_getlist(L, 3);
-        } else if (luaS_ptr_eq(s, box_right_width)) {
+        } else if (lua_key_eq(s, box_right_width)) {
             local_box_right_width(n) = (halfword) lua_tointeger(L, 3);
         } else {
             return nodelib_cantset(L, n, s);
         }
     } else if (t == pdf_start_link_node) {
-        if (luaS_ptr_eq(s, width)) {
+        if (lua_key_eq(s, width)) {
             width(n) = (halfword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, depth)) {
+        } else if (lua_key_eq(s, depth)) {
             depth(n) = (halfword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, height)) {
+        } else if (lua_key_eq(s, height)) {
             height(n) = (halfword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, objnum)) {
+        } else if (lua_key_eq(s, objnum)) {
             pdf_link_objnum(n) = (halfword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, link_attr)) {
+        } else if (lua_key_eq(s, link_attr)) {
             pdf_link_attr(n) = nodelib_gettoks(L, 3);
-        } else if (luaS_ptr_eq(s, action)) {
+        } else if (lua_key_eq(s, action)) {
             pdf_link_action(n) = nodelib_popdirect(n);  /*nodelib_getaction(L, 3);*/
         } else {
             return nodelib_cantset(L, n, s);
         }
     } else if (t == write_node) {
-        if (luaS_ptr_eq(s, stream)) {
+        if (lua_key_eq(s, stream)) {
             write_stream(n) = (halfword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, data)) {
+        } else if (lua_key_eq(s, data)) {
             write_tokens(n) = nodelib_gettoks(L, 3);
         } else {
             return nodelib_cantset(L, n, s);
         }
     } else if (t == pdf_colorstack_node) {
-        if (luaS_ptr_eq(s, stack)) {
+        if (lua_key_eq(s, stack)) {
             pdf_colorstack_stack(n) = (halfword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, command)) {
+        } else if (lua_key_eq(s, command)) {
             pdf_colorstack_cmd(n) = (halfword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, data)) {
+        } else if (lua_key_eq(s, data)) {
             pdf_colorstack_data(n) = nodelib_gettoks(L, 3);
         } else {
             return nodelib_cantset(L, n, s);
         }
     } else if ((t == pdf_thread_node) || (t == pdf_start_thread_node)) {
-        if (luaS_ptr_eq(s, width)) {
+        if (lua_key_eq(s, width)) {
             width(n) = (halfword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, depth)) {
+        } else if (lua_key_eq(s, depth)) {
             depth(n) = (halfword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, height)) {
+        } else if (lua_key_eq(s, height)) {
             height(n) = (halfword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, named_id)) {
+        } else if (lua_key_eq(s, named_id)) {
             pdf_thread_named_id(n) = (quarterword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, thread_id)) {
+        } else if (lua_key_eq(s, thread_id)) {
             if (pdf_thread_named_id(n) == 1) {
                 pdf_thread_id(n) = nodelib_gettoks(L, 3);
             } else {
                 pdf_thread_id(n) = (halfword) lua_tointeger(L, 3);
             }
-        } else if (luaS_ptr_eq(s, thread_attr)) {
+        } else if (lua_key_eq(s, thread_attr)) {
             pdf_thread_attr(n) = nodelib_gettoks(L, 3);
         } else {
             return nodelib_cantset(L, n, s);
         }
     } else if (t == special_node) {
-        if (luaS_ptr_eq(s, data)) {
+        if (lua_key_eq(s, data)) {
             write_tokens(n) = nodelib_gettoks(L, 3);
         } else {
             return nodelib_cantset(L, n, s);
         }
     } else if (t == open_node) {
-        if (luaS_ptr_eq(s, stream)) {
+        if (lua_key_eq(s, stream)) {
             write_stream(n) = (halfword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, name)) {
+        } else if (lua_key_eq(s, name)) {
             open_name(n) = nodelib_getstring(L, 3);
-        } else if (luaS_ptr_eq(s, area)) {
+        } else if (lua_key_eq(s, area)) {
             open_area(n) = nodelib_getstring(L, 3);
-        } else if (luaS_ptr_eq(s, ext)) {
+        } else if (lua_key_eq(s, ext)) {
             open_ext(n) = nodelib_getstring(L, 3);
         } else {
             return nodelib_cantset(L, n, s);
         }
     } else if (t == close_node) {
-        if (luaS_ptr_eq(s, stream)) {
+        if (lua_key_eq(s, stream)) {
             write_stream(n) = (halfword) lua_tointeger(L, 3);
         } else {
             return nodelib_cantset(L, n, s);
@@ -5653,421 +5376,421 @@ static int lua_nodelib_direct_setfield(lua_State * L)
 
     s = lua_tostring(L, 2);
 
-    if (luaS_ptr_eq(s, id)) {
+    if (lua_key_eq(s, id)) {
         lua_pushnumber(L, t);
-    } else if (luaS_ptr_eq(s, next)) {
+    } else if (lua_key_eq(s, next)) {
         halfword x = nodelib_popdirect(3);
         if (x>0 && type(x) == glue_spec_node) {
             return luaL_error(L, "You can't assign a %s node to a next field\n", node_data[type(x)].name);
         }
         vlink(n) = x;
-    } else if (luaS_ptr_eq(s, prev)) {
+    } else if (lua_key_eq(s, prev)) {
         halfword x = nodelib_popdirect(3);
         if (x>0 && type(x) == glue_spec_node) {
             return luaL_error(L, "You can't assign a %s node to a prev field\n", node_data[type(x)].name);
         }
         alink(n) = x;
-    } else if (luaS_ptr_eq(s, attr)) {
+    } else if (lua_key_eq(s, attr)) {
         if (nodetype_has_attributes(type(n))) {
             nodelib_setattr(L, 3, n);
         }
     } else if (t == glyph_node) {
-        if (luaS_ptr_eq(s, subtype)) {
+        if (lua_key_eq(s, subtype)) {
             subtype(n) = (quarterword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, font)) {
+        } else if (lua_key_eq(s, font)) {
             font(n) = (halfword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, char)) {
+        } else if (lua_key_eq(s, char)) {
             character(n) = (halfword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, xoffset)) {
+        } else if (lua_key_eq(s, xoffset)) {
             x_displace(n) = (halfword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, yoffset)) {
+        } else if (lua_key_eq(s, yoffset)) {
             y_displace(n) = (halfword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, width)) {
+        } else if (lua_key_eq(s, width)) {
             /* not yet */
-        } else if (luaS_ptr_eq(s, height)) {
+        } else if (lua_key_eq(s, height)) {
             /* not yet */
-        } else if (luaS_ptr_eq(s, depth)) {
+        } else if (lua_key_eq(s, depth)) {
             /* not yet */
-        } else if (luaS_ptr_eq(s, expansion_factor)) {
+        } else if (lua_key_eq(s, expansion_factor)) {
             ex_glyph(n) = (halfword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, components)) {
+        } else if (lua_key_eq(s, components)) {
             lig_ptr(n) = nodelib_popdirect(3);
-        } else if (luaS_ptr_eq(s, lang)) {
+        } else if (lua_key_eq(s, lang)) {
             set_char_lang(n, (halfword) lua_tointeger(L, 3));
-        } else if (luaS_ptr_eq(s, left)) {
+        } else if (lua_key_eq(s, left)) {
             set_char_lhmin(n, (halfword) lua_tointeger(L, 3));
-        } else if (luaS_ptr_eq(s, right)) {
+        } else if (lua_key_eq(s, right)) {
             set_char_rhmin(n, (halfword) lua_tointeger(L, 3));
-        } else if (luaS_ptr_eq(s, uchyph)) {
+        } else if (lua_key_eq(s, uchyph)) {
             set_char_uchyph(n, (halfword) lua_tointeger(L, 3));
         } else {
             return nodelib_cantset(L, n, s);
         }
     } else if ((t == hlist_node) || (t == vlist_node)) {
-        if (luaS_ptr_eq(s, subtype)) {
+        if (lua_key_eq(s, subtype)) {
             subtype(n) = (quarterword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, list) || luaS_ptr_eq(s, head)) {
+        } else if (lua_key_eq(s, list) || lua_key_eq(s, head)) {
             list_ptr(n) = nodelib_popdirect(3);
-        } else if (luaS_ptr_eq(s, width)) {
+        } else if (lua_key_eq(s, width)) {
             width(n) = (halfword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, height)) {
+        } else if (lua_key_eq(s, height)) {
             height(n) = (halfword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, depth)) {
+        } else if (lua_key_eq(s, depth)) {
             depth(n) = (halfword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, dir)) {
+        } else if (lua_key_eq(s, dir)) {
             box_dir(n) = nodelib_getdir(L, 3, 1);
-        } else if (luaS_ptr_eq(s, shift)) {
+        } else if (lua_key_eq(s, shift)) {
             shift_amount(n) = (halfword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, glue_order)) {
+        } else if (lua_key_eq(s, glue_order)) {
             glue_order(n) = (quarterword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, glue_sign)) {
+        } else if (lua_key_eq(s, glue_sign)) {
             glue_sign(n) = (quarterword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, glue_set)) {
+        } else if (lua_key_eq(s, glue_set)) {
             glue_set(n) = (glue_ratio) lua_tonumber(L, 3);
         } else {
             return nodelib_cantset(L, n, s);
         }
     } else if (t == disc_node) {
-        if (luaS_ptr_eq(s, subtype)) {
+        if (lua_key_eq(s, subtype)) {
             subtype(n) = (quarterword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, pre)) {
+        } else if (lua_key_eq(s, pre)) {
             set_disc_field(pre_break(n), nodelib_popdirect(3));
-        } else if (luaS_ptr_eq(s, post)) {
+        } else if (lua_key_eq(s, post)) {
             set_disc_field(post_break(n), nodelib_popdirect(3));
-        } else if (luaS_ptr_eq(s, replace)) {
+        } else if (lua_key_eq(s, replace)) {
             set_disc_field(no_break(n), nodelib_popdirect(3));
         } else {
             return nodelib_cantset(L, n, s);
         }
     } else if (t == glue_node) {
-        if (luaS_ptr_eq(s, subtype)) {
+        if (lua_key_eq(s, subtype)) {
             subtype(n) = (quarterword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, spec)) {
+        } else if (lua_key_eq(s, spec)) {
             glue_ptr(n) = nodelib_popdirect(3);
-        } else if (luaS_ptr_eq(s, leader)) {
+        } else if (lua_key_eq(s, leader)) {
             leader_ptr(n) = nodelib_popdirect(3);
         } else {
             return nodelib_cantset(L, n, s);
         }
     } else if (t == glue_spec_node) {
-        if (luaS_ptr_eq(s, subtype)) {
+        if (lua_key_eq(s, subtype)) {
             subtype(n) = (quarterword) lua_tointeger(L, 3); /* dummy, the only one that prevents move up */
-        } else if (luaS_ptr_eq(s, width)) {
+        } else if (lua_key_eq(s, width)) {
             width(n) = (halfword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, stretch)) {
+        } else if (lua_key_eq(s, stretch)) {
             stretch(n) = (halfword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, shrink)) {
+        } else if (lua_key_eq(s, shrink)) {
             shrink(n) = (halfword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, stretch_order)) {
+        } else if (lua_key_eq(s, stretch_order)) {
             stretch_order(n) = (quarterword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, shrink_order)) {
+        } else if (lua_key_eq(s, shrink_order)) {
             lua_pushnumber(L, shrink_order(n));
-     /* } else if (luaS_ptr_eq(s, ref_count)) {
+     /* } else if (lua_key_eq(s, ref_count)) {
             glue_ref_count(n) = (halfword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, writable)) {
+        } else if (lua_key_eq(s, writable)) {
      */
         } else {
             return nodelib_cantset(L, n, s);
         }
     } else if (t == kern_node) {
-        if (luaS_ptr_eq(s, subtype)) {
+        if (lua_key_eq(s, subtype)) {
             subtype(n) = (quarterword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, kern)) {
+        } else if (lua_key_eq(s, kern)) {
             width(n) = (halfword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, expansion_factor)) {
+        } else if (lua_key_eq(s, expansion_factor)) {
             ex_kern(n) = (halfword) lua_tointeger(L, 3);
         } else {
             return nodelib_cantset(L, n, s);
         }
     } else if (t == penalty_node) {
-        if (luaS_ptr_eq(s, subtype)) {
+        if (lua_key_eq(s, subtype)) {
             /* dummy subtype */
-        } else if (luaS_ptr_eq(s, penalty)) {
+        } else if (lua_key_eq(s, penalty)) {
             penalty(n) = (halfword) lua_tointeger(L, 3);
         } else {
             return nodelib_cantset(L, n, s);
         }
     } else if (t == rule_node) {
-        if (luaS_ptr_eq(s, subtype)) {
+        if (lua_key_eq(s, subtype)) {
             subtype(n) = (quarterword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, width)) {
+        } else if (lua_key_eq(s, width)) {
             width(n) = (halfword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, height)) {
+        } else if (lua_key_eq(s, height)) {
             height(n) = (halfword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, depth)) {
+        } else if (lua_key_eq(s, depth)) {
             depth(n) = (halfword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, dir)) {
+        } else if (lua_key_eq(s, dir)) {
             rule_dir(n) = nodelib_getdir(L, 3, 1);
         } else {
             return nodelib_cantset(L, n, s);
         }
     } else if (t == whatsit_node) {
-        if (luaS_ptr_eq(s, subtype)) {
+        if (lua_key_eq(s, subtype)) {
             subtype(n) = (quarterword) lua_tointeger(L, 3);
         } else {
             lua_nodelib_direct_setfield_whatsit(L, n, s);
         }
     } else if (t == simple_noad) {
-        if (luaS_ptr_eq(s, subtype)) {
+        if (lua_key_eq(s, subtype)) {
             subtype(n) = (quarterword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, nucleus)) {
+        } else if (lua_key_eq(s, nucleus)) {
             nucleus(n) = nodelib_popdirect(3);
-        } else if (luaS_ptr_eq(s, sub)) {
+        } else if (lua_key_eq(s, sub)) {
             subscr(n) = nodelib_popdirect(3);
-        } else if (luaS_ptr_eq(s, sup)) {
+        } else if (lua_key_eq(s, sup)) {
             supscr(n) = nodelib_popdirect(3);
         } else {
             return nodelib_cantset(L, n, s);
         }
     } else if ((t == math_char_node) || (t == math_text_char_node)) {
-        if (luaS_ptr_eq(s, subtype)) {
+        if (lua_key_eq(s, subtype)) {
             subtype(n) = (quarterword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, fam)) {
+        } else if (lua_key_eq(s, fam)) {
             math_fam(n) = (halfword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, char)) {
+        } else if (lua_key_eq(s, char)) {
             math_character(n) = (halfword) lua_tointeger(L, 3);
         } else {
             return nodelib_cantset(L, n, s);
         }
     } else if (t == mark_node) {
-        if (luaS_ptr_eq(s, subtype)) {
+        if (lua_key_eq(s, subtype)) {
             subtype(n) = (quarterword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, class)) {
+        } else if (lua_key_eq(s, class)) {
             mark_class(n) = (halfword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, mark)) {
+        } else if (lua_key_eq(s, mark)) {
             mark_ptr(n) = nodelib_gettoks(L, 3);
         } else {
             return nodelib_cantset(L, n, s);
         }
     } else if (t == ins_node) {
-        if (luaS_ptr_eq(s, subtype)) {
+        if (lua_key_eq(s, subtype)) {
             subtype(n) = (quarterword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, cost)) {
+        } else if (lua_key_eq(s, cost)) {
             float_cost(n) = (halfword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, depth)) {
+        } else if (lua_key_eq(s, depth)) {
             depth(n) = (halfword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, height)) {
+        } else if (lua_key_eq(s, height)) {
             height(n) = (halfword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, spec)) {
+        } else if (lua_key_eq(s, spec)) {
             split_top_ptr(n) = nodelib_popdirect(3);
-        } else if ((luaS_ptr_eq(s, list)) || (luaS_ptr_eq(s, head))) {
+        } else if ((lua_key_eq(s, list)) || (lua_key_eq(s, head))) {
             ins_ptr(n) = nodelib_popdirect(3);
         } else {
             return nodelib_cantset(L, n, s);
         }
     } else if (t == math_node) {
-        if (luaS_ptr_eq(s, subtype)) {
+        if (lua_key_eq(s, subtype)) {
             subtype(n) = (quarterword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, surround)) {
+        } else if (lua_key_eq(s, surround)) {
             surround(n) = (halfword) lua_tointeger(L, 3);
         } else {
             return nodelib_cantset(L, n, s);
         }
     } else if (t == fraction_noad) {
-        if (luaS_ptr_eq(s, subtype)) {
+        if (lua_key_eq(s, subtype)) {
             subtype(n) = (quarterword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, width)) {
+        } else if (lua_key_eq(s, width)) {
             thickness(n) = (halfword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, num)) {
+        } else if (lua_key_eq(s, num)) {
             numerator(n) = nodelib_popdirect(3);
-        } else if (luaS_ptr_eq(s, denom)) {
+        } else if (lua_key_eq(s, denom)) {
             denominator(n) = nodelib_popdirect(3);
-        } else if (luaS_ptr_eq(s, left)) {
+        } else if (lua_key_eq(s, left)) {
             left_delimiter(n) = nodelib_popdirect(3);
-        } else if (luaS_ptr_eq(s, right)) {
+        } else if (lua_key_eq(s, right)) {
             right_delimiter(n) = nodelib_popdirect(3);
         } else {
             return nodelib_cantset(L, n, s);
         }
     } else if (t == style_node) {
-        if (luaS_ptr_eq(s, subtype)) {
+        if (lua_key_eq(s, subtype)) {
             /* dummy subtype */
-        } else if (luaS_ptr_eq(s, style)) {
+        } else if (lua_key_eq(s, style)) {
             lua_pushstring(L, math_style_names[subtype(n)]);
         } else {
             /* return nodelib_cantset(L, n, s); */
             subtype(n) = (quarterword) luaL_checkoption(L, 2, "text", math_style_names); /* was 3 */
         }
     } else if (t == accent_noad) {
-        if (luaS_ptr_eq(s, subtype)) {
+        if (lua_key_eq(s, subtype)) {
             subtype(n) = (quarterword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, nucleus)) {
+        } else if (lua_key_eq(s, nucleus)) {
             nucleus(n) = nodelib_popdirect(3);
-        } else if (luaS_ptr_eq(s, sub)) {
+        } else if (lua_key_eq(s, sub)) {
             subscr(n) = nodelib_popdirect(3);
-        } else if (luaS_ptr_eq(s, sup)) {
+        } else if (lua_key_eq(s, sup)) {
             supscr(n) = nodelib_popdirect(3);
-        } else if (luaS_ptr_eq(s, accent)) {
+        } else if (lua_key_eq(s, accent)) {
             accent_chr(n) = nodelib_popdirect(3);
-        } else if (luaS_ptr_eq(s, bot_accent)) {
+        } else if (lua_key_eq(s, bot_accent)) {
             bot_accent_chr(n) = nodelib_popdirect(3);
         } else {
             return nodelib_cantset(L, n, s);
         }
     } else if (t == fence_noad) {
-        if (luaS_ptr_eq(s, subtype)) {
+        if (lua_key_eq(s, subtype)) {
             subtype(n) = (quarterword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, delim)) {
+        } else if (lua_key_eq(s, delim)) {
             delimiter(n) = nodelib_popdirect(3);
         } else {
             return nodelib_cantset(L, n, s);
         }
     } else if (t == delim_node) {
-        if (luaS_ptr_eq(s, subtype)) {
+        if (lua_key_eq(s, subtype)) {
             subtype(n) = (quarterword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, small_fam)) {
+        } else if (lua_key_eq(s, small_fam)) {
             small_fam(n) = (halfword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, small_char)) {
+        } else if (lua_key_eq(s, small_char)) {
             small_char(n) = (halfword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, large_fam)) {
+        } else if (lua_key_eq(s, large_fam)) {
             large_fam(n) = (halfword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, large_char)) {
+        } else if (lua_key_eq(s, large_char)) {
             large_char(n) = (halfword) lua_tointeger(L, 3);
         } else {
             return nodelib_cantset(L, n, s);
         }
     } else if ((t == sub_box_node) || (t == sub_mlist_node)) {
-        if (luaS_ptr_eq(s, subtype)) {
+        if (lua_key_eq(s, subtype)) {
             subtype(n) = (quarterword) lua_tointeger(L, 3);
-        } else if ((luaS_ptr_eq(s, list)) || (luaS_ptr_eq(s, head))){
+        } else if ((lua_key_eq(s, list)) || (lua_key_eq(s, head))){
             math_list(n) = nodelib_popdirect(3);
         } else {
             return nodelib_cantset(L, n, s);
         }
     } else if (t == radical_noad) {
-        if (luaS_ptr_eq(s, subtype)) {
+        if (lua_key_eq(s, subtype)) {
             subtype(n) = (quarterword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, nucleus)) {
+        } else if (lua_key_eq(s, nucleus)) {
             nucleus(n) = nodelib_popdirect(3);
-        } else if (luaS_ptr_eq(s, sub)) {
+        } else if (lua_key_eq(s, sub)) {
             subscr(n) = nodelib_popdirect(3);
-        } else if (luaS_ptr_eq(s, sup)) {
+        } else if (lua_key_eq(s, sup)) {
             supscr(n) = nodelib_popdirect(3);
-        } else if (luaS_ptr_eq(s, left)) {
+        } else if (lua_key_eq(s, left)) {
             left_delimiter(n) = nodelib_popdirect(3);
-        } else if (luaS_ptr_eq(s, degree)) {
+        } else if (lua_key_eq(s, degree)) {
             degree(n) = nodelib_popdirect(3);
         } else {
             return nodelib_cantset(L, n, s);
         }
     } else if (t == margin_kern_node) {
-        if (luaS_ptr_eq(s, subtype)) {
+        if (lua_key_eq(s, subtype)) {
             subtype(n) = (quarterword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, width)) {
+        } else if (lua_key_eq(s, width)) {
             width(n) = (halfword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, glyph)) {
+        } else if (lua_key_eq(s, glyph)) {
             margin_char(n) = nodelib_popdirect(3);
         } else {
             return nodelib_cantset(L, n, s);
         }
     } else if (t == split_up_node) {
-        if (luaS_ptr_eq(s, subtype)) {
+        if (lua_key_eq(s, subtype)) {
             subtype(n) = (quarterword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, last_ins_ptr)) {
+        } else if (lua_key_eq(s, last_ins_ptr)) {
             last_ins_ptr(n) = nodelib_popdirect(3);
-        } else if (luaS_ptr_eq(s, best_ins_ptr)) {
+        } else if (lua_key_eq(s, best_ins_ptr)) {
             best_ins_ptr(n) = nodelib_popdirect(3);
-        } else if (luaS_ptr_eq(s, broken_ptr)) {
+        } else if (lua_key_eq(s, broken_ptr)) {
             broken_ptr(n) = nodelib_popdirect(3);
-        } else if (luaS_ptr_eq(s, broken_ins)) {
+        } else if (lua_key_eq(s, broken_ins)) {
             broken_ins(n) = nodelib_popdirect(3);
         } else {
             return nodelib_cantset(L, n, s);
         }
     } else if (t == choice_node) {
-        if (luaS_ptr_eq(s, subtype)) {
+        if (lua_key_eq(s, subtype)) {
             subtype(n) = (quarterword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, display)) {
+        } else if (lua_key_eq(s, display)) {
             display_mlist(n) = nodelib_popdirect(3);
-        } else if (luaS_ptr_eq(s, text)) {
+        } else if (lua_key_eq(s, text)) {
             text_mlist(n) = nodelib_popdirect(3);
-        } else if (luaS_ptr_eq(s, script)) {
+        } else if (lua_key_eq(s, script)) {
             script_mlist(n) = nodelib_popdirect(3);
-        } else if (luaS_ptr_eq(s, scriptscript)) {
+        } else if (lua_key_eq(s, scriptscript)) {
             script_script_mlist(n) = nodelib_popdirect(3);
         } else {
             return nodelib_cantset(L, n, s);
         }
     } else if (t == inserting_node) {
-        if (luaS_ptr_eq(s, subtype)) {
+        if (lua_key_eq(s, subtype)) {
             subtype(n) = (quarterword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, last_ins_ptr)) {
+        } else if (lua_key_eq(s, last_ins_ptr)) {
             last_ins_ptr(n) = nodelib_popdirect(3);
-        } else if (luaS_ptr_eq(s, best_ins_ptr)) {
+        } else if (lua_key_eq(s, best_ins_ptr)) {
             best_ins_ptr(n) = nodelib_popdirect(3);
         } else {
             return nodelib_cantset(L, n, s);
         }
     } else if (t == attribute_node) {
-        if (luaS_ptr_eq(s, subtype)) {
+        if (lua_key_eq(s, subtype)) {
             /* dummy subtype */
-        } else if (luaS_ptr_eq(s, number)) {
+        } else if (lua_key_eq(s, number)) {
             attribute_id(n) = (halfword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, value)) {
+        } else if (lua_key_eq(s, value)) {
             attribute_value(n) = (halfword) lua_tointeger(L, 3);
         } else {
             return nodelib_cantset(L, n, s);
         }
     } else if (t == adjust_node) {
-        if (luaS_ptr_eq(s, subtype)) {
+        if (lua_key_eq(s, subtype)) {
             subtype(n) = (quarterword) lua_tointeger(L, 3);
-        } else if ((luaS_ptr_eq(s, list)) || (luaS_ptr_eq(s, head))) {
+        } else if ((lua_key_eq(s, list)) || (lua_key_eq(s, head))) {
             adjust_ptr(n) = nodelib_popdirect(3);
         } else {
             return nodelib_cantset(L, n, s);
         }
     } else if (t == action_node) {
-        if (luaS_ptr_eq(s, subtype)) {
+        if (lua_key_eq(s, subtype)) {
             /* dummy subtype */
-        } else if (luaS_ptr_eq(s, action_type)) {
+        } else if (lua_key_eq(s, action_type)) {
             pdf_action_type(n) = (quarterword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, named_id)) {
+        } else if (lua_key_eq(s, named_id)) {
             pdf_action_named_id(n) = (quarterword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, action_id)) {
+        } else if (lua_key_eq(s, action_id)) {
             if (pdf_action_named_id(n) == 1) {
                 pdf_action_id(n) = nodelib_gettoks(L, 3);
             } else {
                 pdf_action_id(n) = (halfword) lua_tointeger(L, 3);
             }
-        } else if (luaS_ptr_eq(s, file)) {
+        } else if (lua_key_eq(s, file)) {
             pdf_action_file(n) = nodelib_gettoks(L, 3);
-        } else if (luaS_ptr_eq(s, new_window)) {
+        } else if (lua_key_eq(s, new_window)) {
             pdf_action_new_window(n) = (halfword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, data)) {
+        } else if (lua_key_eq(s, data)) {
             pdf_action_tokens(n) = nodelib_gettoks(L, 3);
-     /* } else if (luaS_ptr_eq(s, ref_count)) {
+     /* } else if (lua_key_eq(s, ref_count)) {
             pdf_action_refcount(n) = (halfword) lua_tointeger(L, 3); */
         } else {
             return nodelib_cantset(L, n, s);
         }
     } else if (t == unset_node) {
-        if (luaS_ptr_eq(s, subtype)) {
+        if (lua_key_eq(s, subtype)) {
             /* dummy subtype */
-        } else if (luaS_ptr_eq(s, width)) {
+        } else if (lua_key_eq(s, width)) {
             width(n) = (halfword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, height)) {
+        } else if (lua_key_eq(s, height)) {
             height(n) = (halfword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, depth)) {
+        } else if (lua_key_eq(s, depth)) {
             depth(n) = (halfword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, dir)) {
+        } else if (lua_key_eq(s, dir)) {
             box_dir(n) = nodelib_getdir(L, 3, 1);
-        } else if (luaS_ptr_eq(s, shrink)) {
+        } else if (lua_key_eq(s, shrink)) {
             glue_shrink(n) = (halfword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, glue_order)) {
+        } else if (lua_key_eq(s, glue_order)) {
             glue_order(n) = (quarterword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, glue_sign)) {
+        } else if (lua_key_eq(s, glue_sign)) {
             glue_sign(n) = (quarterword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, stretch)) {
+        } else if (lua_key_eq(s, stretch)) {
             glue_stretch(n) = (halfword) lua_tointeger(L, 3);
-        } else if (luaS_ptr_eq(s, count)) {
+        } else if (lua_key_eq(s, count)) {
             span_count(n) = (quarterword) lua_tointeger(L, 3);
-        } else if ((luaS_ptr_eq(s, list)) || (luaS_ptr_eq(s, head))){
+        } else if ((lua_key_eq(s, list)) || (lua_key_eq(s, head))){
             list_ptr(n) = nodelib_popdirect(3);
         } else {
             return nodelib_cantset(L, n, s);
         }
     } else if (t == attribute_list_node) {
-        if (luaS_ptr_eq(s, subtype)) {
+        if (lua_key_eq(s, subtype)) {
             /* dummy subtype */
         } else {
             return nodelib_cantset(L, n, s);
@@ -6159,7 +5882,7 @@ static int lua_nodelib_direct_setbox(lua_State * L)
     int n = lua_gettop(L);
     if (n == 3 && lua_isstring(L, 1)) {
         const char *s = lua_tostring(L, 1);
-        if (luaS_ptr_eq(s, global))
+        if (lua_key_eq(s, global))
             isglobal = 1;
     }
     return direct_vsetbox(L, isglobal);
@@ -6232,6 +5955,238 @@ static int lua_nodelib_direct_is_node(lua_State * L)
 
 */
 
+/* if really needed we can provide this:
+
+static int lua_nodelib_attributes_to_table(lua_State * L) // hh
+{   // <node|direct>
+    halfword n;
+    register halfword attribute;
+    if (lua_isnumber(L,1)) {
+        n = lua_tonumber(L,1);
+    } else {
+        n = *((halfword *) lua_touserdata(L, 1));
+    }
+    if ((n == null) || (! nodetype_has_attributes(type(n)))) {
+        lua_pushnil(L);
+    } else {
+        attribute = node_attr(n);
+        if (attribute == null || (attribute == cache_disabled)) {
+            lua_pushnil(L);
+        } else {
+            if (! lua_istable(L,2)) {
+                lua_newtable(L);
+            }
+            while (attribute != null) {
+                lua_pushnumber(L,(int)attribute_id(attribute));
+                lua_pushnumber(L,(int)attribute_value(attribute));
+                lua_rawset(L,-3);
+                attribute = vlink(attribute) ;
+            }
+        }
+    }
+    return 1 ;
+}
+
+*/
+
+/* There is no gain here but let's keep it around:
+
+static int lua_nodelib_attributes_to_properties(lua_State * L)
+{   // <node|direct>
+    halfword n;
+    register halfword attribute;
+    if (lua_isnumber(L,1)) {
+        n = lua_tonumber(L,1);
+    } else {
+        n = *((halfword *) lua_touserdata(L, 1));
+    }
+    if (n == null) {
+        lua_pushnil(L);
+        return 1;
+    }
+    lua_rawgeti(L, LUA_REGISTRYINDEX, luaS_index(node_properties));
+    lua_gettable(L, LUA_REGISTRYINDEX);
+    while (n != null) {
+        lua_rawseti(L, -1, luaS_index(attributes));
+        lua_newtable(L);
+        if (! nodetype_has_attributes(type(n))) {
+            lua_pushnil(L);
+        } else {
+            attribute = node_attr(n);
+            if (attribute == null || (attribute == cache_disabled)) {
+                lua_pushnil(L);
+            } else {
+                while (attribute != null) {
+                    lua_pushnumber(L,(int)attribute_id(attribute));
+                    lua_pushnumber(L,(int)attribute_value(attribute));
+                    lua_rawset(L,-3);
+                    attribute = vlink(attribute) ;
+                }
+            }
+        }
+        lua_rawset(Luas,-3);
+        n = vlink(n);
+    }
+    return 1 ;
+}
+
+*/
+
+/* Beware, enabling and disabling can result in an inconsistent properties table
+but it might make sense sometimes. Of course by default we have disabled this
+mechanism. And, one can always sweep the table empty. */
+
+static int lua_nodelib_properties_set_mode(lua_State * L) /* hh */
+{   /* <boolean> */
+    if (lua_isboolean(L,1)) {
+        lua_properties_enabled = lua_toboolean(L,1);
+    }
+    if (lua_isboolean(L,2)) {
+        lua_properties_use_metatable = lua_toboolean(L,2);
+    }
+    return 0;
+}
+
+/* We used to have variants in assigned defaults but they made no sense. */
+
+static int lua_nodelib_properties_flush_table(lua_State * L) /* hh */
+{   /* <node|direct> <number> */
+    lua_rawgeti(L, LUA_REGISTRYINDEX, lua_key_index(node_properties));
+    lua_gettable(L, LUA_REGISTRYINDEX);
+    lua_pushnil(L); /* initializes lua_next */
+    while (lua_next(L,-2) != 0) {
+        lua_pushvalue(L,-2);
+        lua_pushnil(L);
+        lua_settable(L,-5);
+        lua_pop(L,1);
+    }
+    return 1;
+}
+
+/* maybe we should allocate a proper index 0..var_mem_max but not now */
+
+static int lua_nodelib_get_property(lua_State * L) /* hh */
+{   /* <node> */
+    halfword n;
+    n = *((halfword *) lua_touserdata(L, 1));
+    if (n == null) {
+        lua_pushnil(L);
+    } else {
+        lua_rawgeti(L, LUA_REGISTRYINDEX, lua_key_index(node_properties));
+        lua_gettable(L, LUA_REGISTRYINDEX);
+        lua_rawgeti(L,-1,n);
+    }
+    return 1;
+}
+
+static int lua_nodelib_direct_get_property(lua_State * L) /* hh */
+{   /* <direct> */
+    halfword n = lua_tonumber(L, 1);
+    if (n == null) {
+        lua_pushnil(L);
+    } else {
+        lua_rawgeti(L, LUA_REGISTRYINDEX, lua_key_index(node_properties));
+        lua_gettable(L, LUA_REGISTRYINDEX);
+        lua_rawgeti(L,-1,n);
+    }
+    return 1;
+}
+
+static int lua_nodelib_set_property(lua_State * L) /* hh */
+{
+    /* <node> <value> */
+    halfword n;
+    n = *((halfword *) lua_touserdata(L, 1));
+    if (n != null) {
+        lua_settop(L,2);
+        lua_rawgeti(L, LUA_REGISTRYINDEX, lua_key_index(node_properties));
+        lua_gettable(L, LUA_REGISTRYINDEX);
+        /* <node> <value> <propertytable> */
+        lua_replace(L,-3);
+        /* <propertytable> <value> */
+        lua_rawseti(L,-2,n);
+    }
+    return 0;
+}
+
+static int lua_nodelib_direct_set_property(lua_State * L) /* hh */
+{
+    /* <direct> <value> */
+    halfword n = lua_tonumber(L, 1);
+    if (n != null) { // we could store in node instead */
+        lua_settop(L,2);
+        lua_rawgeti(L, LUA_REGISTRYINDEX, lua_key_index(node_properties));
+        lua_gettable(L, LUA_REGISTRYINDEX);
+        /* <node> <value> <propertytable> */
+        lua_replace(L,1);
+        /* <propertytable> <value> */
+        lua_rawseti(L,1,n);
+    }
+    return 0;
+}
+
+static int lua_nodelib_direct_properties_get_table(lua_State * L) /* hh */
+{   /* <node|direct> */
+    lua_rawgeti(L, LUA_REGISTRYINDEX, lua_key_index(node_properties));
+    lua_gettable(L, LUA_REGISTRYINDEX);
+    return 1;
+}
+
+static int lua_nodelib_properties_get_table(lua_State * L) /* hh */
+{   /* <node|direct> */
+    lua_rawgeti(L, LUA_REGISTRYINDEX, lua_key_index(node_properties_indirect));
+    lua_gettable(L, LUA_REGISTRYINDEX);
+    return 1;
+}
+
+/* bonus */
+
+static int lua_nodelib_get_property_t(lua_State * L) /* hh */
+{   /* <table> <node> */
+    halfword n;
+    n = *((halfword *) lua_touserdata(L, 2));
+    if (n == null) {
+        lua_pushnil(L);
+    } else {
+        lua_rawgeti(L,1,n);
+    }
+    return 1;
+}
+
+static int lua_nodelib_set_property_t(lua_State * L) /* hh */
+{
+    /* <table> <node> <value> */
+    halfword n;
+    n = *((halfword *) lua_touserdata(L, 2));
+    if (n != null) {
+        lua_settop(L,3);
+        lua_rawseti(L,1,n);
+    }
+    return 0;
+}
+
+static const struct luaL_Reg nodelib_p[] = {
+    {"__index",    lua_nodelib_get_property_t},
+    {"__newindex", lua_nodelib_set_property_t},
+    {NULL, NULL} /* sentinel */
+};
+
+static void lua_new_properties_table(lua_State * L) /* hh */
+{
+    lua_pushstring(L,"node.properties");
+    lua_newtable(L);
+    lua_settable(L,LUA_REGISTRYINDEX);
+
+    lua_pushstring(L,"node.properties.indirect");
+    lua_newtable(L);
+    luaL_newmetatable(L,"node.properties.indirect.meta");
+    luaL_register(L, NULL, nodelib_p);
+    lua_setmetatable(L,-2);
+    lua_settable(L,LUA_REGISTRYINDEX);
+}
+
+/* end of properties experiment */
+
 /* node.direct.* */
 
 static const struct luaL_Reg direct_nodelib_f[] = {
@@ -6272,7 +6227,7 @@ static const struct luaL_Reg direct_nodelib_f[] = {
     {"last_node", lua_nodelib_direct_last_node},
     {"length", lua_nodelib_direct_length},
  /* {"ligaturing", font_tex_ligaturing}, */                   /* maybe direct too (rather basic callback exposure) */
- /* {"mlist_to_hlist", lua_nodelib_mlist_to_hlist}, */        /* maybe direct too (rather basic callback exposure) */
+ /* {"mlist_to_hlist", lua_nodelib_mlist_to_hset_properties_modelist}, */        /* maybe direct too (rather basic callback exposure) */
     {"new", lua_nodelib_direct_new},
  /* {"next", lua_nodelib_next}, */                            /* replaced by getnext */
  /* {"prev", lua_nodelib_prev}, */                            /* replaced by getprev */
@@ -6298,6 +6253,15 @@ static const struct luaL_Reg direct_nodelib_f[] = {
     {"vpack", lua_nodelib_direct_vpack},
  /* {"whatsits", lua_nodelib_whatsits}, */                    /* no node argument */
     {"write", lua_nodelib_direct_append},
+    /* an experiment */
+ /* {"attributes_to_table",lua_nodelib_attributes_to_table}, */ /* hh experiment */
+    /* an experiment */
+    {"set_properties_mode",lua_nodelib_properties_set_mode}, /* hh experiment */
+    {"flush_properties_table",lua_nodelib_properties_flush_table}, /* hh experiment */
+    {"get_properties_table",lua_nodelib_direct_properties_get_table}, /* hh experiment */
+    {"getproperty", lua_nodelib_direct_get_property}, /* bonus */ /* hh experiment */
+    {"setproperty", lua_nodelib_direct_set_property}, /* bonus */ /* hh experiment */
+    /* done */
     {NULL, NULL} /* sentinel */
 };
 
@@ -6364,6 +6328,15 @@ static const struct luaL_Reg nodelib_f[] = {
     {"vpack", lua_nodelib_vpack},
     {"whatsits", lua_nodelib_whatsits},
     {"write", lua_nodelib_append},
+    /* experiment */
+ /* {"attributes_to_table",lua_nodelib_attributes_to_table}, */ /* hh experiment */
+    /* experiment */
+    {"set_properties_mode",lua_nodelib_properties_set_mode}, /* hh experiment */
+    {"flush_properties_table",lua_nodelib_properties_flush_table}, /* hh experiment */
+    {"get_properties_table",lua_nodelib_properties_get_table}, /* bonus */ /* hh experiment */
+    {"getproperty", lua_nodelib_get_property}, /* hh experiment */
+    {"setproperty", lua_nodelib_set_property}, /* hh experiment */
+    /* done */
     {NULL, NULL} /* sentinel */
 };
 
@@ -6377,6 +6350,9 @@ static const struct luaL_Reg nodelib_m[] = {
 
 int luaopen_node(lua_State * L)
 {
+
+    lua_new_properties_table(L);
+
     /* the main metatable of node userdata */
     luaL_newmetatable(L, NODE_METATABLE);
     /* node.* */
@@ -6394,7 +6370,7 @@ int luaopen_node(lua_State * L)
     luaL_register(L, NULL, direct_nodelib_f);
     lua_rawset(L,-3);
     /* initialization of keywords */
-    initialize_luaS_indexes(L);
+    /*initialize_luaS_indexes(L);*/
     return 1;
 }
 
diff --git a/source/texk/web2c/luatexdir/lua/lpdflib.c b/source/texk/web2c/luatexdir/lua/lpdflib.c
index ee9fe08cdfe01bc10814b6a59dc828147d8afeed..013140a339954d43bb0849c3b081a81bb01b915d 100644
--- a/source/texk/web2c/luatexdir/lua/lpdflib.c
+++ b/source/texk/web2c/luatexdir/lua/lpdflib.c
@@ -24,7 +24,7 @@ static const char _svn_version[] =
 #include "ptexlib.h"
 #include "lua/luatex-api.h"
 
-#define PDF_ENV "pdf_env"
+#define PDF_ENV "pdf.env"
 
 static int luapdfprint(lua_State * L)
 {
@@ -236,8 +236,9 @@ static int table_obj(lua_State * L)
 
     /* get object "type" */
 
-    lua_pushstring(L, "type");  /* ks t */
-    lua_gettable(L, -2);        /* vs? t */
+    /* lua_pushstring(L, "type");  /\* ks t *\/ */
+    /* lua_gettable(L, -2);        /\* vs? t *\/ */
+    lua_key_rawgeti(type);
     if (lua_isnil(L, -1))       /* !vs t */
         luaL_error(L, "pdf.obj(): object \"type\" missing");
     if (!lua_isstring(L, -1))   /* !vs t */
@@ -261,8 +262,9 @@ static int table_obj(lua_State * L)
 
     /* get optional "immediate" */
 
-    lua_pushstring(L, "immediate");     /* ks t */
-    lua_gettable(L, -2);        /* b? t */
+    /* lua_pushstring(L, "immediate");     /\* ks t *\/ */
+    /* lua_gettable(L, -2);        /\* b? t *\/ */
+    lua_key_rawgeti(immediate);
     if (!lua_isnil(L, -1)) {    /* b? t */
         if (!lua_isboolean(L, -1))      /* !b t */
             luaL_error(L, "pdf.obj(): \"immediate\" must be boolean");
@@ -272,8 +274,9 @@ static int table_obj(lua_State * L)
 
     /* is a reserved object referenced by "objnum"? */
 
-    lua_pushstring(L, "objnum");        /* ks t */
-    lua_gettable(L, -2);        /* vi? t */
+    /* lua_pushstring(L, "objnum");        /\* ks t *\/ */
+    /* lua_gettable(L, -2);        /\* vi? t *\/ */
+    lua_key_rawgeti(objnum);
     if (!lua_isnil(L, -1)) {    /* vi? t */
         if (!lua_isnumber(L, -1))       /* !vi t */
             luaL_error(L, "pdf.obj(): \"objnum\" must be integer");
@@ -294,8 +297,9 @@ static int table_obj(lua_State * L)
 
     /* get optional "attr" (allowed only for stream case) */
 
-    lua_pushstring(L, "attr");  /* ks t */
-    lua_gettable(L, -2);        /* attr-s? t */
+    /* lua_pushstring(L, "attr");  /\* ks t *\/ */
+    /* lua_gettable(L, -2);        /\* attr-s? t *\/ */
+    lua_key_rawgeti(attr);
     if (!lua_isnil(L, -1)) {    /* attr-s? t */
         if (type != P_STREAM)
             luaL_error(L,
@@ -312,8 +316,9 @@ static int table_obj(lua_State * L)
 
     /* get optional "compresslevel" (allowed only for stream case) */
 
-    lua_pushstring(L, "compresslevel"); /* ks t */
-    lua_gettable(L, -2);        /* vi? t */
+    /* lua_pushstring(L, "compresslevel"); /\* ks t *\/ */
+    /* lua_gettable(L, -2);        /\* vi? t *\/ */
+    lua_key_rawgeti(compresslevel);
     if (!lua_isnil(L, -1)) {    /* vi? t */
         if (type == P_RAW)
             luaL_error(L,
@@ -332,8 +337,9 @@ static int table_obj(lua_State * L)
 
     /* get optional "objcompression" (allowed only for non-stream case) */
 
-    lua_pushstring(L, "objcompression");        /* ks t */
-    lua_gettable(L, -2);        /* b? t */
+    /* lua_pushstring(L, "objcompression");        /\* ks t *\/ */
+    /* lua_gettable(L, -2);        /\* b? t *\/ */
+    lua_key_rawgeti(objcompression);
     if (!lua_isnil(L, -1)) {    /* b? t */
         if (type == P_STREAM)
             luaL_error(L,
@@ -353,10 +359,14 @@ static int table_obj(lua_State * L)
 
     /* now the object contents for all cases are handled */
 
-    lua_pushstring(L, "string");        /* ks t */
-    lua_gettable(L, -2);        /* string-s? t */
-    lua_pushstring(L, "file");  /* ks string-s? t */
-    lua_gettable(L, -3);        /* file-s? string-s? t */
+    /* lua_pushstring(L, "string");        /\* ks t *\/ */
+    /* lua_gettable(L, -2);        /\* string-s? t *\/ */
+    lua_key_rawgeti(string);
+    /* lua_pushstring(L, "file");  /\* ks string-s? t *\/ */
+    /* lua_gettable(L, -3);        /\* file-s? string-s? t *\/ */
+    lua_rawgeti(L, LUA_REGISTRYINDEX, lua_key_index(file));
+    lua_gettable(L, -3);     
+
     if (!lua_isnil(L, -1) && !lua_isnil(L, -2)) /* file-s? string-s? t */
         luaL_error(L,
                    "pdf.obj(): \"string\" and \"file\" must not be given together");
@@ -788,7 +798,7 @@ int luaopen_pdf(lua_State * L)
     preset_environment(L, pdf_parms, PDF_ENV);
     luaL_register(L, "pdf", pdflib);
     /* build meta table */
-    luaL_newmetatable(L, "pdf_meta");
+    luaL_newmetatable(L, "pdf.meta");
     lua_pushstring(L, "__index");
     lua_pushcfunction(L, getpdf);
     /* do these later, NYI */
diff --git a/source/texk/web2c/luatexdir/lua/lstatslib.c b/source/texk/web2c/luatexdir/lua/lstatslib.c
index fe70d305c023fee34c0c3090f13b3e00736d2fd8..d8f2fbc2eee634355b4f72aafeb5c6fac87dbdbf 100644
--- a/source/texk/web2c/luatexdir/lua/lstatslib.c
+++ b/source/texk/web2c/luatexdir/lua/lstatslib.c
@@ -78,6 +78,18 @@ static const char *luatexrevision(void)
     return (const char *) (strrchr(luatex_version_string, '.') + 1);
 }
 
+
+static const char *get_luatexhashtype(void) 
+{
+#ifdef LuajitTeX
+     return (const char *)jithash_hashname; 
+#else
+  return "luatex";
+#endif
+}
+
+
+
 static lua_Number get_pdf_gone(void)
 {
     if (static_pdf != NULL)
@@ -172,6 +184,9 @@ static struct statistic stats[] = {
     {"luatex_svn", 'G', &get_luatexsvn},
     {"luatex_version", 'G', &get_luatexversion},
     {"luatex_revision", 'S', (void *) &luatexrevision},
+    {"luatex_hashtype", 'S', (void *) &get_luatexhashtype},
+
+
     {"ini_version", 'b', &ini_version},
     /*
      * mem stat
@@ -344,7 +359,7 @@ static const struct luaL_Reg statslib[] = {
 int luaopen_stats(lua_State * L)
 {
     luaL_register(L, "status", statslib);
-    luaL_newmetatable(L, "stats_meta");
+    luaL_newmetatable(L, "tex.stats");
     lua_pushstring(L, "__index");
     lua_pushcfunction(L, getstats);
     lua_settable(L, -3);
diff --git a/source/texk/web2c/luatexdir/lua/ltexiolib.c b/source/texk/web2c/luatexdir/lua/ltexiolib.c
index a3d939f1cd7740bd96d3556c0f1ed5f4ae5f0fc7..6e296897e55a2550691f546202e5eba35d99a114 100644
--- a/source/texk/web2c/luatexdir/lua/ltexiolib.c
+++ b/source/texk/web2c/luatexdir/lua/ltexiolib.c
@@ -27,18 +27,19 @@ typedef void (*texio_printer) (const char *);
 
 static char *loggable_info = NULL;
 
+
 static boolean get_selector_value(lua_State * L, int i, int *l)
 {
     boolean r = false;
     if (lua_isstring(L, i)) {
         const char *s = lua_tostring(L, i);
-        if (strcmp(s, "log") == 0) {
+        if (lua_key_eq(s,log)) {
             *l = log_only;
             r = true;
-        } else if (strcmp(s, "term") == 0) {
+        } else if (lua_key_eq(s,term)) {
             *l = term_only;
             r = true;
-        } else if (strcmp(s, "term and log") == 0) {
+        } else if (lua_key_eq(s,term_and_log)) {
             *l = term_and_log;
             r = true;
         }
diff --git a/source/texk/web2c/luatexdir/lua/ltexlib.c b/source/texk/web2c/luatexdir/lua/ltexlib.c
index d6081fb96cbbfc730cdd01032e0f853b2656dda2..6505e9aad460eddb1cda829b2c15d67e67b28c2f 100644
--- a/source/texk/web2c/luatexdir/lua/ltexlib.c
+++ b/source/texk/web2c/luatexdir/lua/ltexlib.c
@@ -37,6 +37,11 @@ static const char _svn_version[] =
 #define count(A) eqtb[count_base+(A)].hh.rh
 #define box(A) equiv(box_base+(A))
 
+/* tex random generators */
+extern int unif_rand(int );
+extern int norm_rand(void );
+extern void init_randoms(int );
+
 
 typedef struct {
     char *text;
@@ -102,8 +107,8 @@ static int do_luacprint(lua_State * L, int partial, int deftable)
             cattable=(int)lua_tonumber(L, 1);
             startstrings = 2;
             if (cattable != -1 && cattable != -2 && !valid_catcode_table(cattable)) {
-	      cattable = DEFAULT_CAT_TABLE;
-	    }
+       cattable = DEFAULT_CAT_TABLE;
+     }
         }
     }
     if (lua_type(L, startstrings) == LUA_TTABLE) {
@@ -123,10 +128,24 @@ static int do_luacprint(lua_State * L, int partial, int deftable)
             }
             luac_store(L, i, partial, cattable);
         }
+        /* hh: We could use this but it makes not much different, apart from allocating more ropes so less
+           memory. To be looked into: lua 5.2 buffer mechanism as now we still hash the concatination. This
+           test was part of the why-eis-luajit-so-slow on crited experiments. */
+        /*
+        if (startstrings == n) {
+            luac_store(L, n, partial, cattable);
+        } else {
+            lua_concat(L,n-startstrings+1);
+            luac_store(L, startstrings, partial, cattable);
+        }
+        */
     }
     return 0;
 }
 
+
+
+
 static int luacwrite(lua_State * L)
 {
     return do_luacprint(L, FULL_LINE, NO_CAT_TABLE);
@@ -686,7 +705,7 @@ static int setdimen(lua_State * L)
     int n = lua_gettop(L);
     if (n == 3 && lua_isstring(L, 1)) {
         const char *s = lua_tostring(L, 1);
-        if (strcmp(s, "global") == 0)
+        if (lua_key_eq(s,global))
             isglobal = 1;
     }
     return vsetdimen(L, isglobal);
@@ -729,7 +748,7 @@ static int setskip(lua_State * L)
     int n = lua_gettop(L);
     if (n == 3 && lua_isstring(L, 1)) {
         const char *s = lua_tostring(L, 1);
-        if (strcmp(s, "global") == 0)
+        if (lua_key_eq(s,global))
             isglobal = 1;
     }
     return vsetskip(L, isglobal);
@@ -773,7 +792,7 @@ static int setcount(lua_State * L)
     int n = lua_gettop(L);
     if (n == 3 && lua_isstring(L, 1)) {
         const char *s = lua_tostring(L, 1);
-        if (strcmp(s, "global") == 0)
+        if (lua_key_eq(s,global))
             isglobal = 1;
     }
     return vsetcount(L, isglobal);
@@ -816,7 +835,7 @@ static int setattribute(lua_State * L)
     int n = lua_gettop(L);
     if (n == 3 && lua_isstring(L, 1)) {
         const char *s = lua_tostring(L, 1);
-        if (strcmp(s, "global") == 0)
+        if (lua_key_eq(s,global))
             isglobal = 1;
     }
     return vsetattribute(L, isglobal);
@@ -868,7 +887,7 @@ static int settoks(lua_State * L)
     int n = lua_gettop(L);
     if (n == 3 && lua_isstring(L, 1)) {
         const char *s = lua_tostring(L, 1);
-        if (strcmp(s, "global") == 0)
+        if (lua_key_eq(s,global))
             isglobal = 1;
     }
     return vsettoks(L, isglobal);
@@ -962,7 +981,7 @@ static int setbox(lua_State * L)
     int n = lua_gettop(L);
     if (n == 3 && lua_isstring(L, 1)) {
         const char *s = lua_tostring(L, 1);
-        if (strcmp(s, "global") == 0)
+        if (lua_key_eq(s,global))
             isglobal = 1;
     }
     return vsetbox(L, isglobal);
@@ -985,7 +1004,7 @@ static int setcode (lua_State *L, void (*setone)(int,halfword,quarterword),
 	f++;
     if (n>2 && lua_isstring(L, f)) {
         const char *s = lua_tostring(L, f);
-        if (strcmp(s, "global") == 0) {
+        if (lua_key_eq(s,global)) {
             level = level_one;
 	    f++;
 	}
@@ -1054,7 +1073,7 @@ static int setcatcode(lua_State * L)
 	f++;
     if (n>2 && lua_isstring(L, f)) {
         const char *s = lua_tostring(L, f);
-        if (strcmp(s, "global") == 0) {
+        if (lua_key_eq(s,global)) {
             level = level_one;
 	    f++;
 	}
@@ -1094,7 +1113,7 @@ static int setmathcode(lua_State * L)
 	f++;
     if (n>2 && lua_isstring(L, f)) {
         const char *s = lua_tostring(L, f);
-        if (strcmp(s, "global") == 0) {
+        if (lua_key_eq(s,global)) {
             level = level_one;
 	    f++;
 	}
@@ -1149,7 +1168,7 @@ static int setdelcode(lua_State * L)
 	f++;
     if (n>2 && lua_isstring(L, f)) {
         const char *s = lua_tostring(L, f);
-        if (strcmp(s, "global") == 0) {
+        if (lua_key_eq(s,global)) {
             level = level_one;
 	    f++;
 	}
@@ -1215,7 +1234,7 @@ static int settex(lua_State * L)
         if (is_primitive(texstr)) {
             if (i == 3 && lua_isstring(L, 1)) {
                 const char *s = lua_tostring(L, 1);
-                if (strcmp(s, "global") == 0)
+                if (lua_key_eq(s,global))
                     isglobal = 1;
             }
             cur_cs1 = string_lookup(st, k);
@@ -1439,7 +1458,7 @@ static int tex_setmathparm(lua_State * L)
     if ((n == 3) || (n == 4)) {
         if (n == 4 && lua_isstring(L, 1)) {
             const char *s = lua_tostring(L, 1);
-            if (strcmp(s, "global") == 0)
+            if (lua_key_eq(s,global))
                 l = 1;
         }
         i = luaL_checkoption(L, (n - 2), NULL, math_param_names);
@@ -1600,44 +1619,44 @@ static int getlist(lua_State * L)
     const char *str;
     if (lua_isstring(L, 2)) {
         str = lua_tostring(L, 2);
-        if (strcmp(str, "page_ins_head") == 0) {
+        if (lua_key_eq(str,page_ins_head)) {
             if (vlink(page_ins_head) == page_ins_head)
                 lua_pushnumber(L, null);
             else
                 lua_pushnumber(L, vlink(page_ins_head));
             lua_nodelib_push(L);
-        } else if (strcmp(str, "contrib_head") == 0) {
+        } else if (lua_key_eq(str,contrib_head)) {
 	    alink(vlink(contrib_head)) = null ;
             lua_pushnumber(L, vlink(contrib_head));
             lua_nodelib_push(L);
-        } else if (strcmp(str, "page_head") == 0) {
+        } else if (lua_key_eq(str,page_head)) {
 	    alink(vlink(page_head)) = null ;/*hh-ls */
             lua_pushnumber(L, vlink(page_head));
             lua_nodelib_push(L);
-        } else if (strcmp(str, "temp_head") == 0) {
+        } else if (lua_key_eq(str,temp_head)) {
 	    alink(vlink(temp_head)) = null ;/*hh-ls */
             lua_pushnumber(L, vlink(temp_head));
             lua_nodelib_push(L);
-        } else if (strcmp(str, "hold_head") == 0) {
+        } else if (lua_key_eq(str,hold_head)) {
             alink(vlink(hold_head)) = null ;/*hh-ls */
             lua_pushnumber(L, vlink(hold_head));
             lua_nodelib_push(L);
-        } else if (strcmp(str, "adjust_head") == 0) {
+        } else if (lua_key_eq(str,adjust_head)) {
             alink(vlink(adjust_head)) = null ;/*hh-ls */
             lua_pushnumber(L, vlink(adjust_head));
             lua_nodelib_push(L);
-        } else if (strcmp(str, "best_page_break") == 0) {
+        } else if (lua_key_eq(str,best_page_break)) {
             lua_pushnumber(L, best_page_break);
             lua_nodelib_push(L);
-        } else if (strcmp(str, "least_page_cost") == 0) {
+        } else if (lua_key_eq(str,least_page_cost)) {
             lua_pushnumber(L, least_page_cost);
-        } else if (strcmp(str, "best_size") == 0) {
+        } else if (lua_key_eq(str,best_size)) {
             lua_pushnumber(L, best_size);
-        } else if (strcmp(str, "pre_adjust_head") == 0) {
+        } else if (lua_key_eq(str,pre_adjust_head)) {
             alink(vlink(pre_adjust_head)) = null ;/*hh-ls */
             lua_pushnumber(L, vlink(pre_adjust_head));
             lua_nodelib_push(L);
-        } else if (strcmp(str, "align_head") == 0) {
+        } else if (lua_key_eq(str,align_head)) {
             alink(vlink(align_head)) = null ;/*hh-ls */
             lua_pushnumber(L, vlink(align_head));
             lua_nodelib_push(L);
@@ -1657,16 +1676,16 @@ static int setlist(lua_State * L)
     halfword n = 0;
     if (lua_isstring(L, 2)) {
         str = lua_tostring(L, 2);
-        if (strcmp(str, "best_size") == 0) {
+        if (lua_key_eq(str,best_size)) {
             best_size = (int) lua_tointeger(L, 3);
-        } else if (strcmp(str, "least_page_cost") == 0) {
+        } else if (lua_key_eq(str,least_page_cost)) {
             least_page_cost = (int) lua_tointeger(L, 3);
         } else {
             if (!lua_isnil(L, 3)) {
                 n_ptr = check_isnode(L, 3);
                 n = *n_ptr;
             }
-            if (strcmp(str, "page_ins_head") == 0) {
+            if (lua_key_eq(str,page_ins_head)) {
                 if (n == 0) {
                     vlink(page_ins_head) = page_ins_head;
                 } else {
@@ -1675,27 +1694,27 @@ static int setlist(lua_State * L)
                     m = tail_of_list(n);
                     vlink(m) = page_ins_head;
                 }
-            } else if (strcmp(str, "contrib_head") == 0) {
+            } else if (lua_key_eq(str,contrib_head)) {
                 vlink(contrib_head) = n;
                 if (n == 0) {
                     contrib_tail = contrib_head;
                 }
-            } else if (strcmp(str, "best_page_break") == 0) {
+            } else if (lua_key_eq(str,best_page_break)) {
                 best_page_break = n;
-            } else if (strcmp(str, "page_head") == 0) {
+            } else if (lua_key_eq(str,page_head)) {
                 vlink(page_head) = n;
                 page_tail = (n == 0 ? page_head : tail_of_list(n));
-            } else if (strcmp(str, "temp_head") == 0) {
+            } else if (lua_key_eq(str,temp_head)) {
                 vlink(temp_head) = n;
-            } else if (strcmp(str, "hold_head") == 0) {
+            } else if (lua_key_eq(str,hold_head)) {
                 vlink(hold_head) = n;
-            } else if (strcmp(str, "adjust_head") == 0) {
+            } else if (lua_key_eq(str,adjust_head)) {
                 vlink(adjust_head) = n;
                 adjust_tail = (n == 0 ? adjust_head : tail_of_list(n));
-            } else if (strcmp(str, "pre_adjust_head") == 0) {
+            } else if (lua_key_eq(str,pre_adjust_head)) {
                 vlink(pre_adjust_head) = n;
                 pre_adjust_tail = (n == 0 ? pre_adjust_head : tail_of_list(n));
-            } else if (strcmp(str, "align_head") == 0) {
+            } else if (lua_key_eq(str,align_head)) {
                 vlink(align_head) = n;
             }
         }
@@ -1710,32 +1729,32 @@ static int lua_nest_getfield(lua_State * L)
     list_state_record *r, **rv = lua_touserdata(L, -2);
     const char *field = lua_tostring(L, -1);
     r = *rv;
-    if (strcmp(field, "mode") == 0) {
+    if (lua_key_eq(field,mode)) {
         lua_pushnumber(L, r->mode_field);
-    } else if (strcmp(field, "head") == 0) {
+    } else if (lua_key_eq(field,head)) {
         lua_nodelib_push_fast(L, r->head_field);
-    } else if (strcmp(field, "tail") == 0) {
+    } else if (lua_key_eq(field,tail)) {
         lua_nodelib_push_fast(L, r->tail_field);
-    } else if (strcmp(field, "delimptr") == 0) {
+    } else if (lua_key_eq(field,delimptr)) {
         lua_pushnumber(L, r->eTeX_aux_field);
         lua_nodelib_push(L);
-    } else if (strcmp(field, "prevgraf") == 0) {
+    } else if (lua_key_eq(field,prevgraf)) {
         lua_pushnumber(L, r->pg_field);
-    } else if (strcmp(field, "modeline") == 0) {
+    } else if (lua_key_eq(field,modeline)) {
         lua_pushnumber(L, r->ml_field);
-    } else if (strcmp(field, "prevdepth") == 0) {
+    } else if (lua_key_eq(field,prevdepth)) {
         lua_pushnumber(L, r->prev_depth_field);
-    } else if (strcmp(field, "spacefactor") == 0) {
+    } else if (lua_key_eq(field,spacefactor)) {
         lua_pushnumber(L, r->space_factor_field);
-    } else if (strcmp(field, "noad") == 0) {
+    } else if (lua_key_eq(field,noad)) {
         lua_pushnumber(L, r->incompleat_noad_field);
         lua_nodelib_push(L);
-    } else if (strcmp(field, "dirs") == 0) {
+    } else if (lua_key_eq(field,dirs)) {
         lua_pushnumber(L, r->dirs_field);
         lua_nodelib_push(L);
-    } else if (strcmp(field, "mathdir") == 0) {
+    } else if (lua_key_eq(field,mathdir)) {
         lua_pushboolean(L, r->math_field);
-    } else if (strcmp(field, "mathstyle") == 0) {
+    } else if (lua_key_eq(field,mathstyle)) {
         lua_pushnumber(L, r->math_style_field);
     } else {
         lua_pushnil(L);
@@ -1750,39 +1769,39 @@ static int lua_nest_setfield(lua_State * L)
     list_state_record *r, **rv = lua_touserdata(L, -3);
     const char *field = lua_tostring(L, -2);
     r = *rv;
-    if (strcmp(field, "mode") == 0) {
+    if (lua_key_eq(field,mode)) {
         i=(int)lua_tonumber(L, -1);
         r->mode_field = i;
-    } else if (strcmp(field, "head") == 0) {
+    } else if (lua_key_eq(field,head)) {
         n = check_isnode(L, -1);
         r->head_field = *n;
-    } else if (strcmp(field, "tail") == 0) {
+    } else if (lua_key_eq(field,tail)) {
         n = check_isnode(L, -1);
         r->tail_field = *n;
-    } else if (strcmp(field, "delimptr") == 0) {
+    } else if (lua_key_eq(field,delimptr)) {
         n = check_isnode(L, -1);
         r->eTeX_aux_field = *n;
-    } else if (strcmp(field, "prevgraf") == 0) {
+    } else if (lua_key_eq(field,prevgraf)) {
         i=(int)lua_tonumber(L, -1);
         r->pg_field = i;
-    } else if (strcmp(field, "modeline") == 0) {
+    } else if (lua_key_eq(field,modeline)) {
         i=(int)lua_tonumber(L, -1);
         r->ml_field = i;
-    } else if (strcmp(field, "prevdepth") == 0) {
+    } else if (lua_key_eq(field,prevdepth)) {
         i=(int)lua_tonumber(L, -1);
         r->prev_depth_field = i;
-    } else if (strcmp(field, "spacefactor") == 0) {
+    } else if (lua_key_eq(field,spacefactor)) {
         i=(int)lua_tonumber(L, -1);
         r->space_factor_field = i;
-    } else if (strcmp(field, "noad") == 0) {
+    } else if (lua_key_eq(field,noad)) {
         n = check_isnode(L, -1);
         r->incompleat_noad_field = *n;
-    } else if (strcmp(field, "dirs") == 0) {
+    } else if (lua_key_eq(field,dirs)) {
         n = check_isnode(L, -1);
         r->dirs_field = *n;
-    } else if (strcmp(field, "mathdir") == 0) {
+    } else if (lua_key_eq(field,mathdir)) {
         r->math_field = lua_toboolean(L, -1);
-    } else if (strcmp(field, "mathstyle") == 0) {
+    } else if (lua_key_eq(field,mathstyle)) {
         i=(int)lua_tonumber(L, -1);
         r->math_style_field = i;
     }
@@ -1818,7 +1837,7 @@ static int getnest(lua_State * L)
         }
     } else if (lua_isstring(L, 2)) {
         const char *s = lua_tostring(L, 2);
-        if (strcmp(s, "ptr") == 0) {
+        if (lua_key_eq(s,ptr)) {
             lua_pushnumber(L, nest_ptr);
         } else {
             lua_pushnil(L);
@@ -1981,21 +2000,21 @@ static int tex_extraprimitives(lua_State * L)
         for (i = 1; i <= n; i++) {
             if (lua_isstring(L, i)) {
                 const char *s = lua_tostring(L, i);
-                if (strcmp(s, "etex") == 0) {
+                if (lua_key_eq(s,etex)) {
                     mask |= etex_command;
-                } else if (strcmp(s, "tex") == 0) {
+                } else if (lua_key_eq(s,tex)) {
                     mask |= tex_command;
-                } else if (strcmp(s, "core") == 0) {
+                } else if (lua_key_eq(s,core)) {
                     mask |= core_command;
-                } else if (strcmp(s, "pdftex") == 0) {
+                } else if (lua_key_eq(s,pdftex)) {
                     mask |= pdftex_command;
-                } else if (strcmp(s, "aleph") == 0) {
+                } else if (lua_key_eq(s,aleph)) {
                     mask |= aleph_command;
-                } else if (strcmp(s, "omega") == 0) {
+                } else if (lua_key_eq(s,omega)) {
                     mask |= omega_command;
-                } else if (strcmp(s, "luatex") == 0) {
+                } else if (lua_key_eq(s,luatex)) {
                     mask |= luatex_command | umath_command;
-                } else if (strcmp(s, "umath") == 0) {
+                } else if (lua_key_eq(s,umath)) {
                     mask |= umath_command;
                 }
             }
@@ -2420,6 +2439,69 @@ static int tex_run_boot(lua_State * L)
 
 }
 
+/* tex random generators */
+static int tex_init_rand(lua_State * L)
+{ 
+  int sp;
+  if (!lua_isnumber(L, 1)) {
+      luaL_error(L, "argument must be a number");
+      return 0;
+  }
+  sp=(int)lua_tonumber(L, 1);
+  init_randoms(sp);
+  return 0;
+}
+
+static int tex_unif_rand(lua_State * L)
+{ 
+  int sp;
+  if (!lua_isnumber(L, 1)) {
+      luaL_error(L, "argument must be a number");
+      return 0;
+  }
+  sp=(int)lua_tonumber(L, 1);
+  lua_pushnumber(L, unif_rand(sp));
+  return 1;
+}
+
+static int tex_norm_rand(lua_State * L)
+{ 
+    lua_pushnumber(L, norm_rand());
+    return 1;
+}
+
+/* Same as lua but  with tex rng */
+static int lua_math_random (lua_State *L) 
+{
+  lua_Number rand_max = 0x7fffffff ;
+  lua_Number r =  unif_rand(rand_max) ;
+  r = (r>=0 ? 0+r : 0-r) ;
+  r = r / rand_max;
+  switch (lua_gettop(L)) {  /* check number of arguments */
+    case 0: {  /* no arguments */
+      lua_pushnumber(L, r);  /* Number between 0 and 1 */
+      break;
+    }
+    case 1: {  /* only upper limit */
+      lua_Number u = luaL_checknumber(L, 1);
+      luaL_argcheck(L, (lua_Number)1.0 <= u, 1, "interval is empty");
+      lua_pushnumber(L, floor(r*u) + (lua_Number)(1.0));  /* [1, u] */
+      break;
+    }
+    case 2: {  /* lower and upper limits */
+      lua_Number l = luaL_checknumber(L, 1);
+      lua_Number u = luaL_checknumber(L, 2);
+      luaL_argcheck(L, l <= u, 2, "interval is empty");
+      lua_pushnumber(L, floor(r*(u-l+1)) + l);  /* [l, u] */
+      break;
+    }
+    default: return luaL_error(L, "wrong number of arguments");
+  }
+  return 1;
+}
+
+
+
 static int tex_run_main(lua_State * L)
 {
     (void) L;
@@ -2455,7 +2537,6 @@ static const struct luaL_Reg texlib[] = {
     {"run", tex_run_main},      /* may be needed  */
     {"finish", tex_run_end},    /* may be needed  */
     {"write", luacwrite},
-    {"write", luacwrite},
     {"print", luacprint},
     {"tprint", luactprint},
     {"error", texerror},
@@ -2513,6 +2594,12 @@ static const struct luaL_Reg texlib[] = {
     {"setmath", tex_setmathparm},
     {"getmath", tex_getmathparm},
     {"linebreak", tex_run_linebreak},
+    /* tex random generators     */
+    {"init_rand",   tex_init_rand},
+    {"uniform_rand",tex_unif_rand},
+    {"normal_rand", tex_norm_rand},
+    {"lua_math_randomseed", tex_init_rand}, /* syntactic sugar  */
+    {"lua_math_random", lua_math_random},
     {NULL, NULL}                /* sentinel */
 };
 
@@ -2520,25 +2607,25 @@ int luaopen_tex(lua_State * L)
 {
     luaL_register(L, "tex", texlib);
     /* *INDENT-OFF* */
-    make_table(L, "attribute",  "getattribute", "setattribute");
-    make_table(L, "skip",       "getskip",      "setskip");
-    make_table(L, "dimen",      "getdimen",     "setdimen");
-    make_table(L, "count",      "getcount",     "setcount");
-    make_table(L, "toks",       "gettoks",      "settoks");
-    make_table(L, "box",        "getbox",       "setbox");
-    make_table(L, "sfcode",     "getsfcode",    "setsfcode");
-    make_table(L, "lccode",     "getlccode",    "setlccode");
-    make_table(L, "uccode",     "getuccode",    "setuccode");
-    make_table(L, "catcode",    "getcatcode",   "setcatcode");
-    make_table(L, "mathcode",   "getmathcode",  "setmathcode");
-    make_table(L, "delcode",    "getdelcode",   "setdelcode");
-    make_table(L, "lists",      "getlist",      "setlist");
-    make_table(L, "nest",       "getnest",      "setnest");
+    make_table(L, "attribute", "tex.attribute"   ,"getattribute", "setattribute");
+    make_table(L, "skip",      "tex.skip"        ,"getskip",      "setskip");
+    make_table(L, "dimen",     "tex.dimen"       ,"getdimen",     "setdimen");
+    make_table(L, "count",     "tex.count"       ,"getcount",     "setcount");
+    make_table(L, "toks",      "tex.toks"        ,"gettoks",      "settoks");
+    make_table(L, "box",       "tex.box"         ,"getbox",       "setbox");
+    make_table(L, "sfcode",    "tex.sfcode"      ,"getsfcode",    "setsfcode");
+    make_table(L, "lccode",    "tex.lccode"      ,"getlccode",    "setlccode");
+    make_table(L, "uccode",    "tex.uccode"      ,"getuccode",    "setuccode");
+    make_table(L, "catcode",   "tex.catcode"     ,"getcatcode",   "setcatcode");
+    make_table(L, "mathcode",   "tex.mathcode"    ,"getmathcode",  "setmathcode");
+    make_table(L, "delcode",   "tex.delcode"     ,"getdelcode",   "setdelcode");
+    make_table(L, "lists",     "tex.lists"       ,"getlist",      "setlist");
+    make_table(L, "nest",      "tex.nest"        ,"getnest",      "setnest");
     /* *INDENT-ON* */
     init_nest_lib(L);
     /* make the meta entries */
     /* fetch it back */
-    luaL_newmetatable(L, "tex_meta");
+    luaL_newmetatable(L, "tex.meta");
     lua_pushstring(L, "__index");
     lua_pushcfunction(L, gettex);
     lua_settable(L, -3);
diff --git a/source/texk/web2c/luatexdir/lua/luainit.w b/source/texk/web2c/luatexdir/lua/luainit.w
index 1a02761b5419f843968bc5481254c10ceba84506..c43774a3d2d58eb1c0400a2e4ba40bd66148a1c8 100644
--- a/source/texk/web2c/luatexdir/lua/luainit.w
+++ b/source/texk/web2c/luatexdir/lua/luainit.w
@@ -28,6 +28,248 @@ static const char _svn_version[] =
 
 #include "lua/luatex-api.h"
 
+/* internalized strings: see luatex-api.h */
+make_lua_key(LTL);
+make_lua_key(MathConstants);
+make_lua_key(RTT);
+make_lua_key(TLT);
+make_lua_key(TRT);
+make_lua_key(accent);
+make_lua_key(action);
+make_lua_key(action_id);
+make_lua_key(action_type);
+make_lua_key(additional);
+make_lua_key(adjust_head);
+make_lua_key(advance);
+make_lua_key(aleph);
+make_lua_key(align_head);
+make_lua_key(area);
+make_lua_key(attr);
+make_lua_key(attributes);
+make_lua_key(auto_expand);
+make_lua_key(best_ins_ptr);
+make_lua_key(best_page_break);
+make_lua_key(best_size);
+make_lua_key(bot);
+make_lua_key(bot_accent);
+make_lua_key(bottom_left);
+make_lua_key(bottom_right);
+make_lua_key(box_left);
+make_lua_key(box_left_width);
+make_lua_key(box_right);
+make_lua_key(box_right_width);
+make_lua_key(broken_ins);
+make_lua_key(broken_ptr);
+make_lua_key(cache);
+make_lua_key(cal_expand_ratio);
+make_lua_key(char);
+make_lua_key(characters);
+make_lua_key(checksum);
+make_lua_key(cidinfo);
+make_lua_key(class);
+make_lua_key(command);
+make_lua_key(commands);
+make_lua_key(comment);
+make_lua_key(components);
+make_lua_key(contrib_head);
+make_lua_key(core);
+make_lua_key(cost);
+make_lua_key(count);
+make_lua_key(data);
+make_lua_key(degree);
+make_lua_key(delim);
+make_lua_key(delimptr);
+make_lua_key(denom);
+make_lua_key(depth);
+make_lua_key(designsize);
+make_lua_key(dest_id);
+make_lua_key(dest_type);
+make_lua_key(dir);
+make_lua_key(dir_h);
+make_lua_key(direction);
+make_lua_key(dirs);
+make_lua_key(display);
+make_lua_key(down);
+make_lua_key(dvi_ptr);
+make_lua_key(embedding);
+make_lua_key(encodingbytes);
+make_lua_key(encodingname);
+make_lua_key(end);
+make_lua_key(etex);
+make_lua_key(exactly);
+make_lua_key(expansion_factor);
+make_lua_key(ext);
+make_lua_key(extend);
+make_lua_key(extender);
+make_lua_key(extensible);
+make_lua_key(extra_space);
+make_lua_key(fam);
+make_lua_key(fast);
+make_lua_key(file);
+make_lua_key(filename);
+make_lua_key(font);
+make_lua_key(fonts);
+make_lua_key(format);
+make_lua_key(fullname);
+make_lua_key(global);
+make_lua_key(glue_order);
+make_lua_key(glue_set);
+make_lua_key(glue_sign);
+make_lua_key(glyph);
+make_lua_key(head);
+make_lua_key(height);
+make_lua_key(hold_head);
+make_lua_key(horiz_variants);
+make_lua_key(hyphenchar);
+make_lua_key(id);
+make_lua_key(image);
+make_lua_key(index);
+make_lua_key(italic);
+make_lua_key(kern);
+make_lua_key(kerns);
+make_lua_key(lang);
+make_lua_key(large_char);
+make_lua_key(large_fam);
+make_lua_key(last_ins_ptr);
+make_lua_key(leader);
+make_lua_key(least_page_cost);
+make_lua_key(left);
+make_lua_key(left_boundary);
+make_lua_key(left_protruding);
+make_lua_key(level);
+make_lua_key(ligatures);
+make_lua_key(link_attr);
+make_lua_key(list);
+make_lua_key(log);
+make_lua_key(lua);
+make_lua_key(luatex);
+make_lua_key(luatex_node);
+make_lua_key(mLTL);
+make_lua_key(mRTT);
+make_lua_key(mTLT);
+make_lua_key(mTRT);
+make_lua_key(mark);
+make_lua_key(mathdir);
+make_lua_key(mathkern);
+make_lua_key(mathstyle);
+make_lua_key(mid);
+make_lua_key(mode);
+make_lua_key(modeline);
+make_lua_key(name);
+make_lua_key(named_id);
+make_lua_key(new_window);
+make_lua_key(next);
+make_lua_key(no);
+make_lua_key(noad);
+make_lua_key(node);
+make_lua_key(node_properties);
+make_lua_key(node_properties_indirect);
+make_lua_key(nomath);
+make_lua_key(nop);
+make_lua_key(nucleus);
+make_lua_key(num);
+make_lua_key(number);
+make_lua_key(objnum);
+make_lua_key(omega);
+make_lua_key(ordering);
+make_lua_key(pLTL);
+make_lua_key(pRTT);
+make_lua_key(pTLT);
+make_lua_key(pTRT);
+make_lua_key(page_head);
+make_lua_key(page_ins_head);
+make_lua_key(parameters);
+make_lua_key(pdftex);
+make_lua_key(pen_broken);
+make_lua_key(pen_inter);
+make_lua_key(penalty);
+make_lua_key(pop);
+make_lua_key(post);
+make_lua_key(pre);
+make_lua_key(pre_adjust_head);
+make_lua_key(prev);
+make_lua_key(prevdepth);
+make_lua_key(prevgraf);
+make_lua_key(psname);
+make_lua_key(ptr);
+make_lua_key(push);
+make_lua_key(quad);
+make_lua_key(ref_count);
+make_lua_key(reg);
+make_lua_key(registry);
+make_lua_key(renew);
+make_lua_key(rep);
+make_lua_key(replace);
+make_lua_key(right);
+make_lua_key(right_boundary);
+make_lua_key(right_protruding);
+make_lua_key(rule);
+make_lua_key(scale);
+make_lua_key(script);
+make_lua_key(scriptscript);
+make_lua_key(shift);
+make_lua_key(shrink);
+make_lua_key(shrink_order);
+make_lua_key(size);
+make_lua_key(skewchar);
+make_lua_key(slant);
+make_lua_key(slot);
+make_lua_key(small_char);
+make_lua_key(small_fam);
+make_lua_key(space);
+make_lua_key(space_shrink);
+make_lua_key(space_stretch);
+make_lua_key(spacefactor);
+make_lua_key(spec);
+make_lua_key(special);
+make_lua_key(stack);
+make_lua_key(start);
+make_lua_key(step);
+make_lua_key(stream);
+make_lua_key(stretch);
+make_lua_key(stretch_order);
+make_lua_key(string);
+make_lua_key(style);
+make_lua_key(sub);
+make_lua_key(subst_ex_font);
+make_lua_key(subtype);
+make_lua_key(sup);
+make_lua_key(supplement);
+make_lua_key(surround);
+make_lua_key(tail);
+make_lua_key(temp_head);
+make_lua_key(term);
+make_lua_key(term_and_log);
+make_lua_key(tex);
+make_lua_key(text);
+make_lua_key(thread_attr);
+make_lua_key(thread_id);
+make_lua_key(top);
+make_lua_key(top_accent);
+make_lua_key(top_left);
+make_lua_key(top_right);
+make_lua_key(tounicode);
+make_lua_key(transform);
+make_lua_key(type);
+make_lua_key(uchyph);
+make_lua_key(umath);
+make_lua_key(units_per_em);
+make_lua_key(used);
+make_lua_key(user_id);
+make_lua_key(value);
+make_lua_key(version);
+make_lua_key(vert_variants);
+make_lua_key(width);
+make_lua_key(writable);
+make_lua_key(x_height);
+make_lua_key(xoffset);
+make_lua_key(xyz_zoom);
+make_lua_key(yoffset);
+
+make_lua_key(immediate);
+make_lua_key(compresslevel);
+make_lua_key(objcompression);
+
 @
 TH: TODO
 
@@ -120,6 +362,7 @@ const_string LUATEX_IHELP[] = {
     "  --luaconly               byte-compile a lua file, then exit",
 #ifdef LuajitTeX
     "  --jiton                  turns the JIT compiler on (default off)",
+    "  --jithash=STRING         choose the hash function for the lua strings (lua51|luajit20: default lua51)",
 #endif
     "",
     "See the reference manual for more information about the startup process.",
@@ -189,6 +432,7 @@ int lua_only = 0;
 int lua_offset = 0;
 #ifdef LuajitTeX
 int luajiton   = 0;
+char *jithash_hashname = NULL;
 #endif
 
 int safer_option = 0;
@@ -210,6 +454,7 @@ static struct option long_options[]
 {"luaonly", 0, 0, 0},
 #ifdef LuajitTeX
 {"jiton", 0, 0, 0},
+{"jithash", 1, 0, 0},
 #endif
 {"safer", 0, &safer_option, 1},
 {"nosocket", 0, &nosocket_option, 1},
@@ -251,6 +496,20 @@ static struct option long_options[]
 {0, 0, 0, 0}
 };
 
+@ @c
+int lua_numeric_field_by_index(lua_State * L, int name_index, int dflt)
+{
+    register int i = dflt;
+    lua_rawgeti(L, LUA_REGISTRYINDEX, name_index);      /* fetch the stringptr */
+    lua_rawget(L, -2);
+    if (lua_type(L, -1) == LUA_TNUMBER) {
+        i = lua_roundnumber(L, -1);
+    }
+    lua_pop(L, 1);
+    return i;
+}
+
+
 @ @c
 static void parse_options(int ac, char **av)
 {
@@ -294,6 +553,17 @@ static void parse_options(int ac, char **av)
 #ifdef LuajitTeX
         } else if (ARGUMENT_IS("jiton")) {
             luajiton = 1;
+        } else if (ARGUMENT_IS("jithash")) {
+	      size_t len = strlen(optarg);
+	      if (len<16)
+		jithash_hashname = optarg;     
+	      else{
+		WARNING2("hash name truncated to 15 characters from %d. (%s)",      
+			 (int) len, optarg);
+		jithash_hashname = (string) xmalloc(16);
+                strncpy(jithash_hashname, optarg, 15);
+                jithash_hashname[15] = 0;
+	      }
 #endif
 
         } else if (ARGUMENT_IS("kpathsea-debug")) {
@@ -908,6 +1178,249 @@ void lua_initialize(int ac, char **av)
 
     luainterpreter();
 
+    /* init internalized strings */
+    init_lua_key(LTL);
+    init_lua_key(MathConstants);
+    init_lua_key(RTT);
+    init_lua_key(TLT);
+    init_lua_key(TRT);
+    init_lua_key(accent);
+    init_lua_key(action);
+    init_lua_key(action_id);
+    init_lua_key(action_type);
+    init_lua_key(additional);
+    init_lua_key(adjust_head);
+    init_lua_key(advance);
+    init_lua_key(aleph);
+    init_lua_key(align_head);
+    init_lua_key(area);
+    init_lua_key(attr);
+    init_lua_key(attributes);
+    init_lua_key(auto_expand);
+    init_lua_key(best_ins_ptr);
+    init_lua_key(best_page_break);
+    init_lua_key(best_size);
+    init_lua_key(bot);
+    init_lua_key(bot_accent);
+    init_lua_key(bottom_left);
+    init_lua_key(bottom_right);
+    init_lua_key(box_left);
+    init_lua_key(box_left_width);
+    init_lua_key(box_right);
+    init_lua_key(box_right_width);
+    init_lua_key(broken_ins);
+    init_lua_key(broken_ptr);
+    init_lua_key(cache);
+    init_lua_key(cal_expand_ratio);
+    init_lua_key(char);
+    init_lua_key(characters);
+    init_lua_key(checksum);
+    init_lua_key(cidinfo);
+    init_lua_key(class);
+    init_lua_key(command);
+    init_lua_key(commands);
+    init_lua_key(comment);
+    init_lua_key(components);
+    init_lua_key(contrib_head);
+    init_lua_key(core);
+    init_lua_key(cost);
+    init_lua_key(count);
+    init_lua_key(data);
+    init_lua_key(degree);
+    init_lua_key(delim);
+    init_lua_key(delimptr);
+    init_lua_key(denom);
+    init_lua_key(depth);
+    init_lua_key(designsize);
+    init_lua_key(dest_id);
+    init_lua_key(dest_type);
+    init_lua_key(dir);
+    init_lua_key(dir_h);
+    init_lua_key(direction);
+    init_lua_key(dirs);
+    init_lua_key(display);
+    init_lua_key(down);
+    init_lua_key(dvi_ptr);
+    init_lua_key(embedding);
+    init_lua_key(encodingbytes);
+    init_lua_key(encodingname);
+    init_lua_key(end);
+    init_lua_key(etex);
+    init_lua_key(exactly);
+    init_lua_key(expansion_factor);
+    init_lua_key(ext);
+    init_lua_key(extend);
+    init_lua_key(extender);
+    init_lua_key(extensible);
+    init_lua_key(extra_space);
+    init_lua_key(fam);
+    init_lua_key(fast);
+    init_lua_key(file);
+    init_lua_key(filename);
+    init_lua_key(font);
+    init_lua_key(fonts);
+    init_lua_key(format);
+    init_lua_key(fullname);
+    init_lua_key(global);
+    init_lua_key(glue_order);
+    init_lua_key(glue_set);
+    init_lua_key(glue_sign);
+    init_lua_key(glyph);
+    init_lua_key(head);
+    init_lua_key(height);
+    init_lua_key(hold_head);
+    init_lua_key(horiz_variants);
+    init_lua_key(hyphenchar);
+    init_lua_key(id);
+    init_lua_key(image);
+    init_lua_key(index);
+    init_lua_key(italic);
+    init_lua_key(kern);
+    init_lua_key(kerns);
+    init_lua_key(lang);
+    init_lua_key(large_char);
+    init_lua_key(large_fam);
+    init_lua_key(last_ins_ptr);
+    init_lua_key(leader);
+    init_lua_key(least_page_cost);
+    init_lua_key(left);
+    init_lua_key(left_boundary);
+    init_lua_key(left_protruding);
+    init_lua_key(level);
+    init_lua_key(ligatures);
+    init_lua_key(link_attr);
+    init_lua_key(list);
+    init_lua_key(log);
+    init_lua_key(lua);
+    init_lua_key(luatex);
+    init_lua_key(mark);
+    init_lua_key(mathdir);
+    init_lua_key(mathkern);
+    init_lua_key(mathstyle);
+    init_lua_key(mid);
+    init_lua_key(mode);
+    init_lua_key(modeline);
+    init_lua_key(name);
+    init_lua_key(named_id);
+    init_lua_key(new_window);
+    init_lua_key(next);
+    init_lua_key(no);
+    init_lua_key(noad);
+    init_lua_key(node);
+    init_lua_key(nomath);
+    init_lua_key(nop);
+    init_lua_key(nucleus);
+    init_lua_key(num);
+    init_lua_key(number);
+    init_lua_key(objnum);
+    init_lua_key(omega);
+    init_lua_key(ordering);
+    init_lua_key(page_head);
+    init_lua_key(page_ins_head);
+    init_lua_key(parameters);
+    init_lua_key(pdftex);
+    init_lua_key(pen_broken);
+    init_lua_key(pen_inter);
+    init_lua_key(penalty);
+    init_lua_key(pop);
+    init_lua_key(post);
+    init_lua_key(pre);
+    init_lua_key(pre_adjust_head);
+    init_lua_key(prev);
+    init_lua_key(prevdepth);
+    init_lua_key(prevgraf);
+    init_lua_key(psname);
+    init_lua_key(ptr);
+    init_lua_key(push);
+    init_lua_key(quad);
+    init_lua_key(ref_count);
+    init_lua_key(reg);
+    init_lua_key(registry);
+    init_lua_key(renew);
+    init_lua_key(rep);
+    init_lua_key(replace);
+    init_lua_key(right);
+    init_lua_key(right_boundary);
+    init_lua_key(right_protruding);
+    init_lua_key(rule);
+    init_lua_key(scale);
+    init_lua_key(script);
+    init_lua_key(scriptscript);
+    init_lua_key(shift);
+    init_lua_key(shrink);
+    init_lua_key(shrink_order);
+    init_lua_key(size);
+    init_lua_key(skewchar);
+    init_lua_key(slant);
+    init_lua_key(slot);
+    init_lua_key(small_char);
+    init_lua_key(small_fam);
+    init_lua_key(space);
+    init_lua_key(space_shrink);
+    init_lua_key(space_stretch);
+    init_lua_key(spacefactor);
+    init_lua_key(spec);
+    init_lua_key(special);
+    init_lua_key(stack);
+    init_lua_key(start);
+    init_lua_key(step);
+    init_lua_key(stream);
+    init_lua_key(stretch);
+    init_lua_key(stretch_order);
+    init_lua_key(string);
+    init_lua_key(style);
+    init_lua_key(sub);
+    init_lua_key(subst_ex_font);
+    init_lua_key(subtype);
+    init_lua_key(sup);
+    init_lua_key(supplement);
+    init_lua_key(surround);
+    init_lua_key(tail);
+    init_lua_key(temp_head);
+    init_lua_key(term);
+    init_lua_key(tex);
+    init_lua_key(text);
+    init_lua_key(thread_attr);
+    init_lua_key(thread_id);
+    init_lua_key(top);
+    init_lua_key(top_accent);
+    init_lua_key(top_left);
+    init_lua_key(top_right);
+    init_lua_key(tounicode);
+    init_lua_key(transform);
+    init_lua_key(type);
+    init_lua_key(uchyph);
+    init_lua_key(umath);
+    init_lua_key(units_per_em);
+    init_lua_key(used);
+    init_lua_key(user_id);
+    init_lua_key(value);
+    init_lua_key(version);
+    init_lua_key(vert_variants);
+    init_lua_key(width);
+    init_lua_key(writable);
+    init_lua_key(x_height);
+    init_lua_key(xoffset);
+    init_lua_key(xyz_zoom);
+    init_lua_key(yoffset);
+    init_lua_key_alias(luatex_node, "luatex.node");
+    init_lua_key_alias(mLTL,"-LTL");
+    init_lua_key_alias(mRTT,"-RTT");
+    init_lua_key_alias(mTLT,"-TLT");
+    init_lua_key_alias(mTRT,"-TRT");
+    init_lua_key_alias(node_properties,"node.properties");
+    init_lua_key_alias(node_properties_indirect,"node.properties.indirect");
+    init_lua_key_alias(pLTL,"+LTL");
+    init_lua_key_alias(pRTT,"+RTT");
+    init_lua_key_alias(pTLT,"+TLT");
+    init_lua_key_alias(pTRT,"+TRT");
+    init_lua_key_alias(term_and_log,"term and log");
+
+    init_lua_key(immediate);
+    init_lua_key(compresslevel);
+    init_lua_key(objcompression);
+
+
     prepare_cmdline(Luas, argv, argc, lua_offset);      /* collect arguments */
     setup_lua_path(Luas);
 
diff --git a/source/texk/web2c/luatexdir/lua/luajitstuff.w b/source/texk/web2c/luatexdir/lua/luajitstuff.w
index 0ae3f3f07549f739fd58a5f63d05a958fa1e15a9..6ed6885d493d4459bea02599b431ae27f12bc173 100644
--- a/source/texk/web2c/luatexdir/lua/luajitstuff.w
+++ b/source/texk/web2c/luatexdir/lua/luajitstuff.w
@@ -34,7 +34,7 @@ int luastate_bytes = 0;
 int lua_active = 0;
 
 @ @c
-void make_table(lua_State * L, const char *tab, const char *getfunc,
+void make_table(lua_State * L, const char *tab, const char *mttab, const char *getfunc,
                 const char *setfunc)
 {
     /* make the table *//* |[{<tex>}]| */
@@ -45,7 +45,7 @@ void make_table(lua_State * L, const char *tab, const char *getfunc,
     lua_pushstring(L, tab);     /* |[{<tex>},"dimen"]| */
     lua_gettable(L, -2);        /* |[{<tex>},{<dimen>}]| */
     /* make the meta entries */
-    luaL_newmetatable(L, tab);  /* |[{<tex>},{<dimen>},{<dimen_m>}]| */
+    luaL_newmetatable(L, mttab);  /* |[{<tex>},{<dimen>},{<dimen_m>}]| */
     lua_pushstring(L, "__index");       /* |[{<tex>},{<dimen>},{<dimen_m>},"__index"]| */
     lua_pushstring(L, getfunc); /* |[{<tex>},{<dimen>},{<dimen_m>},"__index","getdimen"]| */
     lua_gettable(L, -5);        /* |[{<tex>},{<dimen>},{<dimen_m>},"__index",<tex.getdimen>]| */
@@ -199,6 +199,25 @@ static int luatex_dofile (lua_State *L) {
 void luainterpreter(void)
 {
     lua_State *L;
+        
+    if (jithash_hashname==NULL){
+	/* default lua51 */ 
+	luajitex_choose_hash_function = 0;
+        jithash_hashname = (char *) xmalloc(strlen("lua51")+1);
+        jithash_hashname = strcpy ( jithash_hashname, "lua51"); 
+    } else {
+      if (strcmp((const char*)jithash_hashname,"lua51")==0){
+	luajitex_choose_hash_function = 0;
+      }else if (strcmp((const char*)jithash_hashname,"luajit20")==0){
+	luajitex_choose_hash_function = 1;
+      } else {
+	/* default lua51 */ 
+	luajitex_choose_hash_function = 0;
+	jithash_hashname = strcpy ( jithash_hashname, "lua51"); 
+      }
+    }
+    
+
     L = luaL_newstate() ;
     /*L = lua_newstate(my_luaalloc, NULL);*/
     if (L == NULL) {
@@ -217,7 +236,6 @@ void luainterpreter(void)
     }
 
 
-
     lua_pushcfunction(L,luatex_dofile);
     lua_setglobal(L, "dofile");
     lua_pushcfunction(L,luatex_loadfile);
@@ -322,6 +340,8 @@ void luainterpreter(void)
         (void) hide_lua_value(L, "lfs", "rmdir");
         (void) hide_lua_value(L, "lfs", "mkdir");
     }
+    /* fprintf(stdout, "\nLuajitTeX default hash function type:%s\n", */
+    /* 		                                jithash_hashname); */
     Luas = L;
 }
 
@@ -392,7 +412,7 @@ int lua_traceback(lua_State * L)
 }
 
 @ @c
-static void luacall(int p, int nameptr, boolean is_string)
+static void luacall(int p, int nameptr, boolean is_string) /* hh-ls: optimized lua_id resolving */
 {
     LoadS ls;
     int i;
@@ -422,18 +442,19 @@ static void luacall(int p, int nameptr, boolean is_string)
         if (nameptr > 0) {
             int l = 0; /* not used */
             lua_id = tokenlist_to_cstring(nameptr, 1, &l);
+            i = lua_load(Luas, getS, &ls, lua_id);
+            xfree(lua_id);
         } else if (nameptr < 0) {
-            char *tmp = get_lua_name((nameptr + 65536));
-            if (tmp != NULL)
-                lua_id = xstrdup(tmp);
-            else
-                lua_id = xstrdup("\\latelua ");
+            lua_id = get_lua_name((nameptr + 65536));
+            if (lua_id != NULL) {
+                i = lua_load(Luas, getS, &ls, lua_id);
+                xfree(lua_id);
+            } else {
+                i = lua_load(Luas, getS, &ls, "\\latelua ");
+            }
         } else {
-            lua_id = xmalloc(20);
-            snprintf((char *) lua_id, 20, "\\latelua ");
+            i = lua_load(Luas, getS, &ls, "\\latelua ");
         }
-
-        i = lua_load(Luas, getS, &ls, lua_id);
         if (i != 0) {
             Luas = luatex_error(Luas, (i == LUA_ERRSYNTAX ? 0 : 1));
         } else {
@@ -448,7 +469,6 @@ static void luacall(int p, int nameptr, boolean is_string)
                 Luas = luatex_error(Luas, (i == LUA_ERRRUN ? 0 : 1));
             }
         }
-        xfree(lua_id);
         xfree(ls.s);
     }
     lua_active--;
@@ -468,7 +488,7 @@ void late_lua(PDF pdf, halfword p)
 }
 
 @ @c
-void luatokencall(int p, int nameptr)
+void luatokencall(int p, int nameptr) /* hh-ls: optimized lua_id resolving */
 {
     LoadS ls;
     int i, l;
@@ -483,16 +503,19 @@ void luatokencall(int p, int nameptr)
     if (ls.size > 0) {
         if (nameptr > 0) {
             lua_id = tokenlist_to_cstring(nameptr, 1, &l);
+            i = lua_load(Luas, getS, &ls, lua_id);
+            xfree(lua_id);
         } else if (nameptr < 0) {
-            char *tmp = get_lua_name((nameptr + 65536));
-            if (tmp != NULL)
-                lua_id = xstrdup(tmp);
-            else
-                lua_id = xstrdup("\\directlua ");
+            lua_id = get_lua_name((nameptr + 65536));
+            if (lua_id != NULL) {
+                i = lua_load(Luas, getS, &ls, lua_id);
+                xfree(lua_id);
+            } else {
+                i = lua_load(Luas, getS, &ls, "\\directlua ");
+            }
         } else {
-            lua_id = xstrdup("\\directlua ");
+            i = lua_load(Luas, getS, &ls, "\\directlua ");
         }
-        i = lua_load(Luas, getS, &ls, lua_id);
         xfree(s);
         if (i != 0) {
             Luas = luatex_error(Luas, (i == LUA_ERRSYNTAX ? 0 : 1));
@@ -508,7 +531,6 @@ void luatokencall(int p, int nameptr)
                 Luas = luatex_error(Luas, (i == LUA_ERRRUN ? 0 : 1));
             }
         }
-        xfree(lua_id);
     }
     lua_active--;
 }
diff --git a/source/texk/web2c/luatexdir/lua/luastuff.w b/source/texk/web2c/luatexdir/lua/luastuff.w
index 48b03a2b8b9bc81d2c26f4c6e77ca5a67f07a624..30884726e28bc2c346210e7136f5fd0bbf9374c1 100644
--- a/source/texk/web2c/luatexdir/lua/luastuff.w
+++ b/source/texk/web2c/luatexdir/lua/luastuff.w
@@ -33,7 +33,7 @@ int luastate_bytes = 0;
 int lua_active = 0;
 
 @ @c
-void make_table(lua_State * L, const char *tab, const char *getfunc,
+void make_table(lua_State * L, const char *tab, const char *mttab, const char *getfunc,
                 const char *setfunc)
 {
     /* make the table *//* |[{<tex>}]| */
@@ -44,7 +44,7 @@ void make_table(lua_State * L, const char *tab, const char *getfunc,
     lua_pushstring(L, tab);     /* |[{<tex>},"dimen"]| */
     lua_gettable(L, -2);        /* |[{<tex>},{<dimen>}]| */
     /* make the meta entries */
-    luaL_newmetatable(L, tab);  /* |[{<tex>},{<dimen>},{<dimen_m>}]| */
+    luaL_newmetatable(L, mttab);  /* |[{<tex>},{<dimen>},{<dimen_m>}]| */
     lua_pushstring(L, "__index");       /* |[{<tex>},{<dimen>},{<dimen_m>},"__index"]| */
     lua_pushstring(L, getfunc); /* |[{<tex>},{<dimen>},{<dimen_m>},"__index","getdimen"]| */
     lua_gettable(L, -5);        /* |[{<tex>},{<dimen>},{<dimen_m>},"__index",<tex.getdimen>]| */
@@ -360,7 +360,7 @@ int lua_traceback(lua_State * L)
 }
 
 @ @c
-static void luacall(int p, int nameptr, boolean is_string)
+static void luacall(int p, int nameptr, boolean is_string) /* hh-ls: optimized lua_id resolving */
 {
     LoadS ls;
     int i;
@@ -390,18 +390,19 @@ static void luacall(int p, int nameptr, boolean is_string)
         if (nameptr > 0) {
             int l = 0; /* not used */
             lua_id = tokenlist_to_cstring(nameptr, 1, &l);
+            i = lua_load(Luas, getS, &ls, lua_id, NULL);
+            xfree(lua_id);
         } else if (nameptr < 0) {
-            char *tmp = get_lua_name((nameptr + 65536));
-            if (tmp != NULL)
-                lua_id = xstrdup(tmp);
-            else
-                lua_id = xstrdup("\\latelua ");
+            lua_id = get_lua_name((nameptr + 65536));
+            if (lua_id != NULL) {
+                i = lua_load(Luas, getS, &ls, lua_id, NULL);
+                xfree(lua_id);
+            } else {
+                i = lua_load(Luas, getS, &ls, "\\latelua ", NULL);
+            }
         } else {
-            lua_id = xmalloc(20);
-            snprintf((char *) lua_id, 20, "\\latelua ");
+            i = lua_load(Luas, getS, &ls, "\\latelua ", NULL);
         }
-
-        i = lua_load(Luas, getS, &ls, lua_id, NULL);
         if (i != 0) {
             Luas = luatex_error(Luas, (i == LUA_ERRSYNTAX ? 0 : 1));
         } else {
@@ -416,7 +417,6 @@ static void luacall(int p, int nameptr, boolean is_string)
                 Luas = luatex_error(Luas, (i == LUA_ERRRUN ? 0 : 1));
             }
         }
-        xfree(lua_id);
         xfree(ls.s);
     }
     lua_active--;
@@ -436,7 +436,7 @@ void late_lua(PDF pdf, halfword p)
 }
 
 @ @c
-void luatokencall(int p, int nameptr)
+void luatokencall(int p, int nameptr) /* hh-ls: optimized lua_id resolving */
 {
     LoadS ls;
     int i, l;
@@ -451,16 +451,19 @@ void luatokencall(int p, int nameptr)
     if (ls.size > 0) {
         if (nameptr > 0) {
             lua_id = tokenlist_to_cstring(nameptr, 1, &l);
+            i = lua_load(Luas, getS, &ls, lua_id, NULL);
+            xfree(lua_id);
         } else if (nameptr < 0) {
-            char *tmp = get_lua_name((nameptr + 65536));
-            if (tmp != NULL)
-                lua_id = xstrdup(tmp);
-            else
-                lua_id = xstrdup("\\directlua ");
+            lua_id = get_lua_name((nameptr + 65536));
+            if (lua_id != NULL) {
+                i = lua_load(Luas, getS, &ls, lua_id, NULL);
+                xfree(lua_id);
+            } else {
+                i = lua_load(Luas, getS, &ls, "\\directlua ", NULL);
+            }
         } else {
-            lua_id = xstrdup("\\directlua ");
+            i = lua_load(Luas, getS, &ls, "\\directlua ", NULL);
         }
-        i = lua_load(Luas, getS, &ls, lua_id, NULL);
         xfree(s);
         if (i != 0) {
             Luas = luatex_error(Luas, (i == LUA_ERRSYNTAX ? 0 : 1));
@@ -476,7 +479,6 @@ void luatokencall(int p, int nameptr)
                 Luas = luatex_error(Luas, (i == LUA_ERRRUN ? 0 : 1));
             }
         }
-        xfree(lua_id);
     }
     lua_active--;
 }
diff --git a/source/texk/web2c/luatexdir/lua/luatex-api.h b/source/texk/web2c/luatexdir/lua/luatex-api.h
index b2305ab5e12ca7e62e5fd61a660a06f730fc97e7..ddbc3c12ce8bacf3ab5b09d40e73d0bb9f2cc47e 100644
--- a/source/texk/web2c/luatexdir/lua/luatex-api.h
+++ b/source/texk/web2c/luatexdir/lua/luatex-api.h
@@ -43,7 +43,7 @@ typedef struct LoadS {
 
 extern lua_State *Luas;
 
-extern void make_table(lua_State * L, const char *tab, const char *getfunc,
+extern void make_table(lua_State * L, const char *tab, const char *mttab, const char *getfunc,
                        const char *setfunc);
 
 extern int luac_main(int argc, char *argv[]);
@@ -136,6 +136,8 @@ extern void undump_luac_registers(void);
 extern int lua_only;
 #ifdef LuajitTeX
 extern int luajiton;
+extern int luajitex_choose_hash_function; 
+extern char *jithash_hashname ;
 #endif
 
 extern void unhide_lua_table(lua_State * lua, const char *name, int r);
@@ -222,4 +224,305 @@ extern char **environ;
 #ifdef __cplusplus
 }
 #endif
+
+/*
+    Same as in lnodelib.c, but with prefix G_ for now.
+    These macros create and access pointers (indices) to keys which is faster. The
+    shortcuts are created as part of the initialization.
+
+*/
+
+/*#define init_luaS_index(a) do {                         */
+#define init_lua_key(a) do {                      \
+    lua_pushliteral(Luas,#a);                             \
+    luaS_##a##_ptr = lua_tostring(Luas,-1);               \
+    luaS_##a##_index = luaL_ref (Luas,LUA_REGISTRYINDEX); \
+} while (0)
+
+  /*#define init_luaS_index_s(a,b) do {           */      
+#define init_lua_key_alias(a,b) do {              \
+    lua_pushliteral(Luas,b);                              \
+    luaS_##a##_ptr = lua_tostring(Luas,-1);               \
+    luaS_##a##_index = luaL_ref (Luas,LUA_REGISTRYINDEX); \
+} while (0)
+
+  /*#define make_luaS_index(a) */                       
+#define make_lua_key(a)       \
+    int luaS_##a##_index = 0;          \
+    const char * luaS_##a##_ptr = NULL
+
+
+/*#define luaS_ptr_eq(a,b) (a==luaS_##b##_ptr)*/
+#define lua_key_eq(a,b) (a==luaS_##b##_ptr)
+
+#define luaS_index(a)    luaS_##a##_index
+#define lua_key_index(a) luaS_##a##_index
+#define lua_key(a) luaS_##a##_ptr
+#define use_lua_key(a)  \
+  extern int luaS_##a##_index ;          \
+  extern const char * luaS_##a##_ptr 
+
+
+#define lua_key_rawgeti(a) \
+  lua_rawgeti(L, LUA_REGISTRYINDEX, luaS_##a##_index);\
+  lua_rawget(L, -2)
+
+
+#define lua_roundnumber(a,b) (int)floor((double)lua_tonumber(L,-1)+0.5)
+extern int lua_numeric_field_by_index(lua_State *, int , int);
+ 
+
 #endif                          /* LUATEX_API_H */
+
+
+
+
+/*                                                 */  
+/* These keys have to available to different files */
+/*                                                 */ 
+
+
+use_lua_key(LTL);
+use_lua_key(MathConstants);
+use_lua_key(RTT);
+use_lua_key(TLT);
+use_lua_key(TRT);
+use_lua_key(accent);
+use_lua_key(action);
+use_lua_key(action_id);
+use_lua_key(action_type);
+use_lua_key(additional);
+use_lua_key(adjust_head);
+use_lua_key(advance);
+use_lua_key(aleph);
+use_lua_key(align_head);
+use_lua_key(area);
+use_lua_key(attr);
+use_lua_key(attributes);
+use_lua_key(auto_expand);
+use_lua_key(best_ins_ptr);
+use_lua_key(best_page_break);
+use_lua_key(best_size);
+use_lua_key(bot);
+use_lua_key(bot_accent);
+use_lua_key(bottom_left);
+use_lua_key(bottom_right);
+use_lua_key(box_left);
+use_lua_key(box_left_width);
+use_lua_key(box_right);
+use_lua_key(box_right_width);
+use_lua_key(broken_ins);
+use_lua_key(broken_ptr);
+use_lua_key(cache);
+use_lua_key(cal_expand_ratio);
+use_lua_key(char);
+use_lua_key(characters);
+use_lua_key(checksum);
+use_lua_key(cidinfo);
+use_lua_key(class);
+use_lua_key(command);
+use_lua_key(commands);
+use_lua_key(comment);
+use_lua_key(components);
+use_lua_key(contrib_head);
+use_lua_key(core);
+use_lua_key(cost);
+use_lua_key(count);
+use_lua_key(data);
+use_lua_key(degree);
+use_lua_key(delim);
+use_lua_key(delimptr);
+use_lua_key(denom);
+use_lua_key(depth);
+use_lua_key(designsize);
+use_lua_key(dest_id);
+use_lua_key(dest_type);
+use_lua_key(dir);
+use_lua_key(dir_h);
+use_lua_key(direction);
+use_lua_key(dirs);
+use_lua_key(display);
+use_lua_key(down);
+use_lua_key(dvi_ptr);
+use_lua_key(embedding);
+use_lua_key(encodingbytes);
+use_lua_key(encodingname);
+use_lua_key(end);
+use_lua_key(etex);
+use_lua_key(exactly);
+use_lua_key(expansion_factor);
+use_lua_key(ext);
+use_lua_key(extend);
+use_lua_key(extender);
+use_lua_key(extensible);
+use_lua_key(extra_space);
+use_lua_key(fam);
+use_lua_key(fast);
+use_lua_key(file);
+use_lua_key(filename);
+use_lua_key(font);
+use_lua_key(fonts);
+use_lua_key(format);
+use_lua_key(fullname);
+use_lua_key(global);
+use_lua_key(glue_order);
+use_lua_key(glue_set);
+use_lua_key(glue_sign);
+use_lua_key(glyph);
+use_lua_key(head);
+use_lua_key(height);
+use_lua_key(hold_head);
+use_lua_key(horiz_variants);
+use_lua_key(hyphenchar);
+use_lua_key(id);
+use_lua_key(image);
+use_lua_key(index);
+use_lua_key(italic);
+use_lua_key(kern);
+use_lua_key(kerns);
+use_lua_key(lang);
+use_lua_key(large_char);
+use_lua_key(large_fam);
+use_lua_key(last_ins_ptr);
+use_lua_key(leader);
+use_lua_key(least_page_cost);
+use_lua_key(left);
+use_lua_key(left_boundary);
+use_lua_key(left_protruding);
+use_lua_key(level);
+use_lua_key(ligatures);
+use_lua_key(link_attr);
+use_lua_key(list);
+use_lua_key(log);
+use_lua_key(lua);
+use_lua_key(luatex);
+use_lua_key(luatex_node);
+use_lua_key(mLTL);
+use_lua_key(mRTT);
+use_lua_key(mTLT);
+use_lua_key(mTRT);
+use_lua_key(mark);
+use_lua_key(mathdir);
+use_lua_key(mathkern);
+use_lua_key(mathstyle);
+use_lua_key(mid);
+use_lua_key(mode);
+use_lua_key(modeline);
+use_lua_key(name);
+use_lua_key(named_id);
+use_lua_key(new_window);
+use_lua_key(next);
+use_lua_key(no);
+use_lua_key(noad);
+use_lua_key(node);
+use_lua_key(node_properties);
+use_lua_key(node_properties_indirect);
+use_lua_key(nomath);
+use_lua_key(nop);
+use_lua_key(nucleus);
+use_lua_key(num);
+use_lua_key(number);
+use_lua_key(objnum);
+use_lua_key(omega);
+use_lua_key(ordering);
+use_lua_key(pLTL);
+use_lua_key(pRTT);
+use_lua_key(pTLT);
+use_lua_key(pTRT);
+use_lua_key(page_head);
+use_lua_key(page_ins_head);
+use_lua_key(parameters);
+use_lua_key(pdftex);
+use_lua_key(pen_broken);
+use_lua_key(pen_inter);
+use_lua_key(penalty);
+use_lua_key(pop);
+use_lua_key(post);
+use_lua_key(pre);
+use_lua_key(pre_adjust_head);
+use_lua_key(prev);
+use_lua_key(prevdepth);
+use_lua_key(prevgraf);
+use_lua_key(psname);
+use_lua_key(ptr);
+use_lua_key(push);
+use_lua_key(quad);
+use_lua_key(ref_count);
+use_lua_key(reg);
+use_lua_key(registry);
+use_lua_key(renew);
+use_lua_key(rep);
+use_lua_key(replace);
+use_lua_key(right);
+use_lua_key(right_boundary);
+use_lua_key(right_protruding);
+use_lua_key(rule);
+use_lua_key(scale);
+use_lua_key(script);
+use_lua_key(scriptscript);
+use_lua_key(shift);
+use_lua_key(shrink);
+use_lua_key(shrink_order);
+use_lua_key(size);
+use_lua_key(skewchar);
+use_lua_key(slant);
+use_lua_key(slot);
+use_lua_key(small_char);
+use_lua_key(small_fam);
+use_lua_key(space);
+use_lua_key(space_shrink);
+use_lua_key(space_stretch);
+use_lua_key(spacefactor);
+use_lua_key(spec);
+use_lua_key(special);
+use_lua_key(stack);
+use_lua_key(start);
+use_lua_key(step);
+use_lua_key(stream);
+use_lua_key(stretch);
+use_lua_key(stretch_order);
+use_lua_key(string);
+use_lua_key(style);
+use_lua_key(sub);
+use_lua_key(subst_ex_font);
+use_lua_key(subtype);
+use_lua_key(sup);
+use_lua_key(supplement);
+use_lua_key(surround);
+use_lua_key(tail);
+use_lua_key(temp_head);
+use_lua_key(term);
+use_lua_key(term_and_log);
+use_lua_key(tex);
+use_lua_key(text);
+use_lua_key(thread_attr);
+use_lua_key(thread_id);
+use_lua_key(top);
+use_lua_key(top_accent);
+use_lua_key(top_left);
+use_lua_key(top_right);
+use_lua_key(tounicode);
+use_lua_key(transform);
+use_lua_key(type);
+use_lua_key(uchyph);
+use_lua_key(umath);
+use_lua_key(units_per_em);
+use_lua_key(used);
+use_lua_key(user_id);
+use_lua_key(value);
+use_lua_key(version);
+use_lua_key(vert_variants);
+use_lua_key(width);
+use_lua_key(writable);
+use_lua_key(x_height);
+use_lua_key(xoffset);
+use_lua_key(xyz_zoom);
+use_lua_key(yoffset);
+
+use_lua_key(immediate);
+use_lua_key(compresslevel);
+use_lua_key(objcompression);
+
+
+
+
diff --git a/source/texk/web2c/luatexdir/luafilesystem/src/lfs.c b/source/texk/web2c/luatexdir/luafilesystem/src/lfs.c
index 6279c0f2b5c3d59c9dc0072cbb4b1fcf3c13dc41..a4e6fc6005f941f90c76de295040bc899c547d85 100644
--- a/source/texk/web2c/luatexdir/luafilesystem/src/lfs.c
+++ b/source/texk/web2c/luatexdir/luafilesystem/src/lfs.c
@@ -74,7 +74,7 @@
 #define getcwd_error	strerror(errno)
 #endif
 
-#define DIR_METATABLE "directory metatable"
+#define DIR_METATABLE "lfs.directory"
 #define MAX_DIR_LENGTH 1023
 typedef struct dir_data {
 	int  closed;
@@ -86,7 +86,7 @@ typedef struct dir_data {
 #endif
 } dir_data;
 
-#define LOCK_METATABLE "lock metatable"
+#define LOCK_METATABLE "lfs.lock"
 
 #ifdef _WIN32
  #ifdef __BORLANDC__
diff --git a/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/parsettf.c b/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/parsettf.c
index 339f99ffc2902a97536431476370e0ab59d8df1f..6782c7e891bb2ee165a0eb4fe7d27947a87b4651 100644
--- a/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/parsettf.c
+++ b/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/parsettf.c
@@ -5657,6 +5657,17 @@ static void PsuedoEncodeUnencoded(EncMap *map,struct ttfinfo *info) {
 	if ( info->chars[i]!=NULL && !info->chars[i]->ticked )
 	    ++extras;
     if ( extras!=0 ) {
+      /* UnicodeBmp has its own   Private Use Areas */
+        /* if (strcmp(map->enc_name","UnicodeBmp")==0) { */
+        /*     if ( (info->glyph_cnt < 0x18FF) && (map->enccount<0xE000)) */
+        /*         base = 0xE000 */
+        /*     else if ( map->enccount<0xF0000 ) */
+        /*         base = 0xF0000; */
+        /*     else if ( map->enccount<0x100000 ) */
+        /*         base = 0x100000; */
+        /*     else */
+        /*         base = map->enccount; */
+        /*   } else { */
 	if ( map->enccount<=256 )
 	    base = 256;
 	else if ( map->enccount<=65536 )
diff --git a/source/texk/web2c/luatexdir/luapeg/lpeg.h b/source/texk/web2c/luatexdir/luapeg/lpeg.h
index 456e8277c7db430c9b75e114d5318c1427084734..fe61485993afcdfeb6ba04ab843bc1455ced1378 100644
--- a/source/texk/web2c/luatexdir/luapeg/lpeg.h
+++ b/source/texk/web2c/luatexdir/luapeg/lpeg.h
@@ -28,8 +28,8 @@
 #define VERSION         "0.12"
 
 
-#define PATTERN_T	"lpeg-pattern"
-#define MAXSTACKIDX	"lpeg-maxstack"
+#define PATTERN_T	"lpeg.pattern"
+#define MAXSTACKIDX	"lpeg.maxstack"
 
 
 /*
diff --git a/source/texk/web2c/luatexdir/luasocket/src/tcp.c b/source/texk/web2c/luatexdir/luasocket/src/tcp.c
index 6734dc0b497a54e1707416497f90548cf01d2c37..e73340314789e950316195cafe63c27a730f47b4 100644
--- a/source/texk/web2c/luatexdir/luasocket/src/tcp.c
+++ b/source/texk/web2c/luatexdir/luasocket/src/tcp.c
@@ -99,13 +99,13 @@ static luaL_Reg func[] = {
 int tcp_open(lua_State *L)
 {
     /* create classes */
-    auxiliar_newclass(L, "tcp{master}", tcp_methods);
-    auxiliar_newclass(L, "tcp{client}", tcp_methods);
-    auxiliar_newclass(L, "tcp{server}", tcp_methods);
+    auxiliar_newclass(L, "tcp.master", tcp_methods);
+    auxiliar_newclass(L, "tcp.client", tcp_methods);
+    auxiliar_newclass(L, "tcp.server", tcp_methods);
     /* create class groups */
-    auxiliar_add2group(L, "tcp{master}", "tcp{any}");
-    auxiliar_add2group(L, "tcp{client}", "tcp{any}");
-    auxiliar_add2group(L, "tcp{server}", "tcp{any}");
+    auxiliar_add2group(L, "tcp.master", "tcp{any}");
+    auxiliar_add2group(L, "tcp.client", "tcp{any}");
+    auxiliar_add2group(L, "tcp.server", "tcp{any}");
     /* define library functions */
     luaL_openlib(L, NULL, func, 0);
     return 0;
@@ -118,22 +118,22 @@ int tcp_open(lua_State *L)
 * Just call buffered IO methods
 \*-------------------------------------------------------------------------*/
 static int meth_send(lua_State *L) {
-    p_tcp tcp = (p_tcp) auxiliar_checkclass(L, "tcp{client}", 1);
+    p_tcp tcp = (p_tcp) auxiliar_checkclass(L, "tcp.client", 1);
     return buffer_meth_send(L, &tcp->buf);
 }
 
 static int meth_receive(lua_State *L) {
-    p_tcp tcp = (p_tcp) auxiliar_checkclass(L, "tcp{client}", 1);
+    p_tcp tcp = (p_tcp) auxiliar_checkclass(L, "tcp.client", 1);
     return buffer_meth_receive(L, &tcp->buf);
 }
 
 static int meth_getstats(lua_State *L) {
-    p_tcp tcp = (p_tcp) auxiliar_checkclass(L, "tcp{client}", 1);
+    p_tcp tcp = (p_tcp) auxiliar_checkclass(L, "tcp.client", 1);
     return buffer_meth_getstats(L, &tcp->buf);
 }
 
 static int meth_setstats(lua_State *L) {
-    p_tcp tcp = (p_tcp) auxiliar_checkclass(L, "tcp{client}", 1);
+    p_tcp tcp = (p_tcp) auxiliar_checkclass(L, "tcp.client", 1);
     return buffer_meth_setstats(L, &tcp->buf);
 }
 
@@ -183,14 +183,14 @@ static int meth_dirty(lua_State *L)
 \*-------------------------------------------------------------------------*/
 static int meth_accept(lua_State *L)
 {
-    p_tcp server = (p_tcp) auxiliar_checkclass(L, "tcp{server}", 1);
+    p_tcp server = (p_tcp) auxiliar_checkclass(L, "tcp.server", 1);
     p_timeout tm = timeout_markstart(&server->tm);
     t_socket sock;
     const char *err = inet_tryaccept(&server->sock, server->family, &sock, tm);
     /* if successful, push client socket */
     if (err == NULL) {
         p_tcp clnt = (p_tcp) lua_newuserdata(L, sizeof(t_tcp));
-        auxiliar_setclass(L, "tcp{client}", -1);
+        auxiliar_setclass(L, "tcp.client", -1);
         /* initialize structure fields */
         memset(clnt, 0, sizeof(t_tcp));
         socket_setnonblocking(&sock);
@@ -213,7 +213,7 @@ static int meth_accept(lua_State *L)
 \*-------------------------------------------------------------------------*/
 static int meth_bind(lua_State *L)
 {
-    p_tcp tcp = (p_tcp) auxiliar_checkclass(L, "tcp{master}", 1);
+    p_tcp tcp = (p_tcp) auxiliar_checkclass(L, "tcp.master", 1);
     const char *address =  luaL_checkstring(L, 2);
     const char *port = luaL_checkstring(L, 3);
     const char *err;
@@ -250,7 +250,7 @@ static int meth_connect(lua_State *L)
     timeout_markstart(&tcp->tm);
     err = inet_tryconnect(&tcp->sock, address, port, &tcp->tm, &connecthints);
     /* have to set the class even if it failed due to non-blocking connects */
-    auxiliar_setclass(L, "tcp{client}", 1);
+    auxiliar_setclass(L, "tcp.client", 1);
     if (err) {
         lua_pushnil(L);
         lua_pushstring(L, err);
@@ -291,7 +291,7 @@ static int meth_getfamily(lua_State *L)
 \*-------------------------------------------------------------------------*/
 static int meth_listen(lua_State *L)
 {
-    p_tcp tcp = (p_tcp) auxiliar_checkclass(L, "tcp{master}", 1);
+    p_tcp tcp = (p_tcp) auxiliar_checkclass(L, "tcp.master", 1);
     int backlog = (int) luaL_optnumber(L, 2, 32);
     int err = socket_listen(&tcp->sock, backlog);
     if (err != IO_DONE) {
@@ -300,7 +300,7 @@ static int meth_listen(lua_State *L)
         return 2;
     }
     /* turn master object into a server object */
-    auxiliar_setclass(L, "tcp{server}", 1);
+    auxiliar_setclass(L, "tcp.server", 1);
     lua_pushnumber(L, 1);
     return 1;
 }
@@ -312,7 +312,7 @@ static int meth_shutdown(lua_State *L)
 {
     /* SHUT_RD,  SHUT_WR,  SHUT_RDWR  have  the value 0, 1, 2, so we can use method index directly */
     static const char* methods[] = { "receive", "send", "both", NULL };
-    p_tcp tcp = (p_tcp) auxiliar_checkclass(L, "tcp{client}", 1);
+    p_tcp tcp = (p_tcp) auxiliar_checkclass(L, "tcp.client", 1);
     int how = luaL_checkoption(L, 2, "both", methods);
     socket_shutdown(&tcp->sock, how);
     lua_pushnumber(L, 1);
@@ -358,7 +358,7 @@ static int tcp_create(lua_State *L, int family) {
         p_tcp tcp = (p_tcp) lua_newuserdata(L, sizeof(t_tcp));
         memset(tcp, 0, sizeof(t_tcp));
         /* set its type as master object */
-        auxiliar_setclass(L, "tcp{master}", -1);
+        auxiliar_setclass(L, "tcp.master", -1);
         /* initialize remaining structure fields */
         socket_setnonblocking(&sock);
         if (family == PF_INET6) {
@@ -470,6 +470,6 @@ static int global_connect(lua_State *L) {
         lua_pushstring(L, err);
         return 2;
     }
-    auxiliar_setclass(L, "tcp{client}", -1);
+    auxiliar_setclass(L, "tcp.client", -1);
     return 1;
 }
diff --git a/source/texk/web2c/luatexdir/luasocket/src/udp.c b/source/texk/web2c/luatexdir/luasocket/src/udp.c
index 8e14fac290f2f59bade88e1f7cad8f8f619e41fa..8e88b1784a265dc36d9ab2c9254c6d02999d7843 100644
--- a/source/texk/web2c/luatexdir/luasocket/src/udp.c
+++ b/source/texk/web2c/luatexdir/luasocket/src/udp.c
@@ -101,13 +101,13 @@ static luaL_Reg func[] = {
 int udp_open(lua_State *L)
 {
     /* create classes */
-    auxiliar_newclass(L, "udp{connected}", udp_methods);
-    auxiliar_newclass(L, "udp{unconnected}", udp_methods);
+    auxiliar_newclass(L, "udp.connected", udp_methods);
+    auxiliar_newclass(L, "udp.unconnected", udp_methods);
     /* create class groups */
-    auxiliar_add2group(L, "udp{connected}",   "udp{any}");
-    auxiliar_add2group(L, "udp{unconnected}", "udp{any}");
-    auxiliar_add2group(L, "udp{connected}",   "select{able}");
-    auxiliar_add2group(L, "udp{unconnected}", "select{able}");
+    auxiliar_add2group(L, "udp.connected",   "udp{any}");
+    auxiliar_add2group(L, "udp.unconnected", "udp{any}");
+    auxiliar_add2group(L, "udp.connected",   "select{able}");
+    auxiliar_add2group(L, "udp.unconnected", "select{able}");
     /* define library functions */
     luaL_openlib(L, NULL, func, 0);
     return 0;
@@ -127,7 +127,7 @@ const char *udp_strerror(int err) {
 * Send data through connected udp socket
 \*-------------------------------------------------------------------------*/
 static int meth_send(lua_State *L) {
-    p_udp udp = (p_udp) auxiliar_checkclass(L, "udp{connected}", 1);
+    p_udp udp = (p_udp) auxiliar_checkclass(L, "udp.connected", 1);
     p_timeout tm = &udp->tm;
     size_t count, sent = 0;
     int err;
@@ -147,7 +147,7 @@ static int meth_send(lua_State *L) {
 * Send data through unconnected udp socket
 \*-------------------------------------------------------------------------*/
 static int meth_sendto(lua_State *L) {
-    p_udp udp = (p_udp) auxiliar_checkclass(L, "udp{unconnected}", 1);
+    p_udp udp = (p_udp) auxiliar_checkclass(L, "udp.unconnected", 1);
     size_t count, sent = 0;
     const char *data = luaL_checklstring(L, 2, &count);
     const char *ip = luaL_checkstring(L, 3);
@@ -221,7 +221,7 @@ static int meth_receive(lua_State *L) {
 * Receives data and sender from a UDP socket
 \*-------------------------------------------------------------------------*/
 static int meth_receivefrom(lua_State *L) {
-    p_udp udp = (p_udp) auxiliar_checkclass(L, "udp{unconnected}", 1);
+    p_udp udp = (p_udp) auxiliar_checkclass(L, "udp.unconnected", 1);
     char buffer[UDP_DATAGRAMSIZE];
     size_t got, count = (size_t) luaL_optnumber(L, 2, sizeof(buffer));
     int err;
@@ -327,7 +327,7 @@ static int meth_dirty(lua_State *L) {
 * Just call inet methods
 \*-------------------------------------------------------------------------*/
 static int meth_getpeername(lua_State *L) {
-    p_udp udp = (p_udp) auxiliar_checkclass(L, "udp{connected}", 1);
+    p_udp udp = (p_udp) auxiliar_checkclass(L, "udp.connected", 1);
     return inet_meth_getpeername(L, &udp->sock, udp->family);
 }
 
@@ -382,12 +382,12 @@ static int meth_setpeername(lua_State *L) {
             lua_pushstring(L, err);
             return 2;
         }
-        auxiliar_setclass(L, "udp{connected}", 1);
+        auxiliar_setclass(L, "udp.connected", 1);
     } else {
         /* we ignore possible errors because Mac OS X always
          * returns EAFNOSUPPORT */
         inet_trydisconnect(&udp->sock, udp->family, tm);
-        auxiliar_setclass(L, "udp{unconnected}", 1);
+        auxiliar_setclass(L, "udp.unconnected", 1);
     }
     /* change class to connected or unconnected depending on address */
     lua_pushnumber(L, 1);
@@ -408,7 +408,7 @@ static int meth_close(lua_State *L) {
 * Turns a master object into a server object
 \*-------------------------------------------------------------------------*/
 static int meth_setsockname(lua_State *L) {
-    p_udp udp = (p_udp) auxiliar_checkclass(L, "udp{unconnected}", 1);
+    p_udp udp = (p_udp) auxiliar_checkclass(L, "udp.unconnected", 1);
     const char *address =  luaL_checkstring(L, 2);
     const char *port = luaL_checkstring(L, 3);
     const char *err;
@@ -440,7 +440,7 @@ static int udp_create(lua_State *L, int family) {
     if (!err) {
         /* allocate udp object */
         p_udp udp = (p_udp) lua_newuserdata(L, sizeof(t_udp));
-        auxiliar_setclass(L, "udp{unconnected}", -1);
+        auxiliar_setclass(L, "udp.unconnected", -1);
         /* initialize remaining structure fields */
         socket_setnonblocking(&sock);
         if (family == PF_INET6) {
diff --git a/source/texk/web2c/luatexdir/luatex-common.h b/source/texk/web2c/luatexdir/luatex-common.h
index a0b34b004769b87ea1b5abdcb1b0b9ea18a2a93a..12ea10be642b4a8925a949aa728a525384facac8 100644
--- a/source/texk/web2c/luatexdir/luatex-common.h
+++ b/source/texk/web2c/luatexdir/luatex-common.h
@@ -27,8 +27,8 @@
 
 /* utils.c */
 __attribute__ ((format(printf, 1, 2)))
-extern void pdftex_warn(const char *fmt, ...);
+extern void luatex_warn(const char *fmt, ...);
 __attribute__ ((noreturn, format(printf, 1, 2)))
-extern void pdftex_fail(const char *fmt, ...);
+extern void luatex_fail(const char *fmt, ...);
 
 #endif /* LUATEX_COMMON_H */
diff --git a/source/texk/web2c/luatexdir/luazip/src/luazip.c b/source/texk/web2c/luatexdir/luazip/src/luazip.c
index a7124498e20a69ae7ba77de5314ddef637435b87..eb731349f0d7b5bbd847d3986f9416e90d3447c2 100644
--- a/source/texk/web2c/luatexdir/luazip/src/luazip.c
+++ b/source/texk/web2c/luatexdir/luazip/src/luazip.c
@@ -14,8 +14,8 @@
 #include "luazip.h"
 #include "lauxlib.h"
 
-#define ZIPFILEHANDLE    "lzipFile"
-#define ZIPINTERNALFILEHANDLE  "lzipInternalFile"
+#define ZIPFILEHANDLE    "lzip.File"
+#define ZIPINTERNALFILEHANDLE  "lzip.InternalFile"
 #define LUAZIP_MAX_EXTENSIONS 32
 
 static int pushresult (lua_State *L, int i, const char *filename) {
diff --git a/source/texk/web2c/luatexdir/luazlib/lgzip.c b/source/texk/web2c/luatexdir/luazlib/lgzip.c
index db9ede71940949351e907f0f6a221597e1090d34..9a10e9242b69b951fe96863525d8788c9f132fde 100644
--- a/source/texk/web2c/luatexdir/luazlib/lgzip.c
+++ b/source/texk/web2c/luatexdir/luazlib/lgzip.c
@@ -45,7 +45,7 @@ Changes:
 */
 
 
-#define FILEHANDLE		"zlib:gzFile"
+#define FILEHANDLE		"zlib.gzFile"
 
 
 static int pushresult (lua_State *L, int i, const char *filename) {
diff --git a/source/texk/web2c/luatexdir/luazlib/lzlib.c b/source/texk/web2c/luatexdir/luazlib/lzlib.c
index 263c6ba611d55cb1117f382fd18a6ef2dfe4abba..a76f54ee0f6364124b450648f7b9f9b027c386d5 100644
--- a/source/texk/web2c/luatexdir/luazlib/lzlib.c
+++ b/source/texk/web2c/luatexdir/luazlib/lzlib.c
@@ -47,7 +47,7 @@ Changes:
 ** zlib stream metamethods
 ** =========================================================================
 */
-#define ZSTREAMMETA "zlib:zstream"
+#define ZSTREAMMETA "zlib.zstream"
 
 #define LZANY     (void*)-1
 #define LZNONE    (void*)0
diff --git a/source/texk/web2c/luatexdir/pdf/pdfcolorstack.w b/source/texk/web2c/luatexdir/pdf/pdfcolorstack.w
index 07ac3aa95d403021844268d7387d7e963bf02095..97370b9ca7d3c8c6af483e4b5cf2ea2da564090e 100644
--- a/source/texk/web2c/luatexdir/pdf/pdfcolorstack.w
+++ b/source/texk/web2c/luatexdir/pdf/pdfcolorstack.w
@@ -239,7 +239,7 @@ int colorstackpop(int colstack_no)
 
     if (global_shipping_mode == SHIPPING_PAGE) {
         if (colstack->page_used == 0) {
-            pdftex_warn("pop empty color page stack %u",
+            luatex_warn("pop empty color page stack %u",
                         (unsigned int) colstack_no);
             return colstack->literal_mode;
         }
@@ -248,7 +248,7 @@ int colorstackpop(int colstack_no)
         put_cstring_on_str_pool(colstack->page_current);
     } else {
         if (colstack->form_used == 0) {
-            pdftex_warn("pop empty color form stack %u",
+            luatex_warn("pop empty color form stack %u",
                         (unsigned int) colstack_no);
             return colstack->literal_mode;
         }
diff --git a/source/texk/web2c/luatexdir/pdf/pdfgen.w b/source/texk/web2c/luatexdir/pdf/pdfgen.w
index 36bc0d4a3af440282a51c6d92608003f962472a7..2d483a1a20112a18f33fd07db561a047dc598f15 100644
--- a/source/texk/web2c/luatexdir/pdf/pdfgen.w
+++ b/source/texk/web2c/luatexdir/pdf/pdfgen.w
@@ -34,7 +34,7 @@ static const char _svn_version[] =
 
 #define check_nprintf(size_get, size_want) \
     if ((unsigned)(size_get) >= (unsigned)(size_want)) \
-        pdftex_fail ("snprintf failed: file %s, line %d", __FILE__, __LINE__);
+        luatex_fail ("snprintf failed: file %s, line %d", __FILE__, __LINE__);
 
 PDF static_pdf = NULL;
 
@@ -300,7 +300,7 @@ void fix_pdf_minorversion(PDF pdf)
 
 #define check_err(f, fn)                        \
   if (f != Z_OK)                                \
-    pdftex_fail("zlib: %s() failed (error code %d)", fn, f)
+    luatex_fail("zlib: %s() failed (error code %d)", fn, f)
 
 @ @c
 static void write_zip(PDF pdf)
@@ -311,7 +311,7 @@ static void write_zip(PDF pdf)
     z_stream *s = pdf->c_stream;
     boolean finish = pdf->zip_write_state == ZIP_FINISH;
     assert(pdf->compress_level > 0);
-    /* This was just to suppress the filename report in |pdftex_fail|
+    /* This was just to suppress the filename report in |luatex_fail|
        but zlib errors are rare enough (especially now that the
        compress level is fixed) that I don't care about the slightly
        ugly error message that could result.
@@ -361,7 +361,7 @@ static void write_zip(PDF pdf)
         }
         err = deflate(s, flush);
         if (err != Z_OK && err != Z_STREAM_END)
-            pdftex_fail("zlib: deflate() failed (error code %d)", err);
+            luatex_fail("zlib: deflate() failed (error code %d)", err);
     }
     pdf->stream_length = (off_t) s->total_out;
 }
@@ -852,7 +852,7 @@ void addto_page_resources(PDF pdf, pdf_obj_type t, int k)
         re->resources_tree =
             avl_create(comp_page_resources, NULL, &avl_xallocator);
         if (re->resources_tree == NULL)
-            pdftex_fail
+            luatex_fail
                 ("addto_page_resources(): avl_create() page_resource_tree failed");
     }
     tmp.obj_type = t;
@@ -863,7 +863,7 @@ void addto_page_resources(PDF pdf, pdf_obj_type t, int k)
         pr->list = NULL;
         pp = avl_probe(re->resources_tree, pr);
         if (pp == NULL)
-            pdftex_fail
+            luatex_fail
                 ("addto_page_resources(): avl_probe() out of memory in insertion");
     }
     if (pr->list == NULL) {
@@ -1515,7 +1515,7 @@ static void print_ID(PDF pdf)
     md5_append(&state, (const md5_byte_t *) time_str, (int) size);
     /* get the file name */
     if (getcwd(pwd, sizeof(pwd)) == NULL)
-        pdftex_fail("getcwd() failed (%s), (path too long?)", strerror(errno));
+        luatex_fail("getcwd() failed (%s), (path too long?)", strerror(errno));
 #ifdef WIN32
     {
         char *p;
@@ -1928,7 +1928,7 @@ void pdf_end_page(PDF pdf)
     /* Finish stream of page/form contents */
     pdf_goto_pagemode(pdf);
     if (pos_stack_used > 0) {
-        pdftex_fail("%u unmatched \\pdfsave after %s shipout",
+        luatex_fail("%u unmatched \\pdfsave after %s shipout",
                     (unsigned int) pos_stack_used,
                     ((global_shipping_mode ==
                       SHIPPING_PAGE) ? "page" : "form"));
diff --git a/source/texk/web2c/luatexdir/pdf/pdfluaapi.w b/source/texk/web2c/luatexdir/pdf/pdfluaapi.w
index 34c0e4bd1b2aaf090a5103f1bef4112fae71fcb9..012ed41013ebeefba04e0e4b247b7d597e7715ee 100644
--- a/source/texk/web2c/luatexdir/pdf/pdfluaapi.w
+++ b/source/texk/web2c/luatexdir/pdf/pdfluaapi.w
@@ -32,14 +32,14 @@ int new_pdflua(void)
     const zlib_struct *zp = pdflua_zlib_struct_ptr;
     uLong uncomprLen = zp->uncomprLen;
     if ((uncompr = xtalloc(zp->uncomprLen, Byte)) == NULL)
-        pdftex_fail("new_pdflua(): xtalloc()");
+        luatex_fail("new_pdflua(): xtalloc()");
     err = uncompress(uncompr, &uncomprLen, zp->compr, zp->comprLen);
     if (err != Z_OK)
-        pdftex_fail("new_pdflua(): uncompress()");
+        luatex_fail("new_pdflua(): uncompress()");
     assert(uncomprLen == zp->uncomprLen);
     if (luaL_loadbuffer(Luas, (const char *) uncompr, uncomprLen, "pdflua")
         || lua_pcall(Luas, 0, 1, 0))
-        pdftex_fail("new_pdflua(): lua_pcall()");
+        luatex_fail("new_pdflua(): lua_pcall()");
     luaL_checktype(Luas, -1, LUA_TTABLE);       /* t */
     i = luaL_ref(Luas, LUA_REGISTRYINDEX);       /* - */
     xfree(uncompr);
@@ -64,7 +64,7 @@ void pdflua_begin_page(PDF pdf)
     lua_setfield(Luas, -2, "resources_objnum"); /* t f t ... */
     err = lua_pcall(Luas, 1, 0, 0);     /* (e) t ... */
     if (err != 0)
-        pdftex_fail("pdflua.lua: beginpage()");
+        luatex_fail("pdflua.lua: beginpage()");
     /* t ... */
     lua_pop(Luas, 1);           /* ... */
 }
@@ -97,7 +97,7 @@ void pdflua_end_page(PDF pdf, int annots, int beads)
     }
     err = lua_pcall(Luas, 1, 0, 0);     /* (e) t ... */
     if (err != 0)
-        pdftex_fail("pdflua.lua: endpage()");
+        luatex_fail("pdflua.lua: endpage()");
     /* t ... */
     lua_pop(Luas, 1);           /* ... */
 }
@@ -111,5 +111,5 @@ void pdflua_output_pages_tree(PDF pdf)
     lua_gettable(Luas, -2);     /* f */
     err = lua_pcall(Luas, 0, 0, 0);     /* - */
     if (err != 0)
-        pdftex_fail("pdflua.lua: outputpagestree()");
+        luatex_fail("pdflua.lua: outputpagestree()");
 }
diff --git a/source/texk/web2c/luatexdir/pdf/pdfsaverestore.w b/source/texk/web2c/luatexdir/pdf/pdfsaverestore.w
index 9fd37eaaa6a1a30d331e7eba3975f130bbe1998c..bdd84f3a77b5c06a6118669ad2b05b06a11e8ba5 100644
--- a/source/texk/web2c/luatexdir/pdf/pdfsaverestore.w
+++ b/source/texk/web2c/luatexdir/pdf/pdfsaverestore.w
@@ -55,14 +55,14 @@ static void checkpdfrestore(scaledpos pos)
 {
     scaledpos diff;
     if (pos_stack_used == 0) {
-        pdftex_warn("%s", "\\pdfrestore: missing \\pdfsave");
+        luatex_warn("%s", "\\pdfrestore: missing \\pdfsave");
         return;
     }
     pos_stack_used--;
     diff.h = pos.h - pos_stack[pos_stack_used].pos.h;
     diff.v = pos.v - pos_stack[pos_stack_used].pos.v;
     if (diff.h != 0 || diff.v != 0) {
-        pdftex_warn("Misplaced \\pdfrestore by (%dsp, %dsp)", (int) diff.h,
+        luatex_warn("Misplaced \\pdfrestore by (%dsp, %dsp)", (int) diff.h,
                     (int) diff.v);
     }
     if (global_shipping_mode == SHIPPING_PAGE) {
diff --git a/source/texk/web2c/luatexdir/pdf/pdfsetmatrix.w b/source/texk/web2c/luatexdir/pdf/pdfsetmatrix.w
index acc35eef4b6903718bb2665ed70bd9d4abcfd353..1ea6e6d58bf636596b94c5ed0929436aa5b7f853 100644
--- a/source/texk/web2c/luatexdir/pdf/pdfsetmatrix.w
+++ b/source/texk/web2c/luatexdir/pdf/pdfsetmatrix.w
@@ -94,7 +94,7 @@ static void pdfsetmatrix(const char *in, scaledpos pos)
     if (global_shipping_mode == SHIPPING_PAGE) {
         if (sscanf((const char *) in, " %lf %lf %lf %lf ",
                    &x.a, &x.b, &x.c, &x.d) != 4) {
-            pdftex_warn("Unrecognized format of \\pdfsetmatrix{%s}", in);
+            luatex_warn("Unrecognized format of \\pdfsetmatrix{%s}", in);
             return;
         }
         /* calculate this transformation matrix */
diff --git a/source/texk/web2c/luatexdir/pdf/pdftables.w b/source/texk/web2c/luatexdir/pdf/pdftables.w
index 8451a3ad658a119dee86d557e65486ff6324db06..c14ba58a4f31884d4b08edb5c97781b2bd288fe5 100644
--- a/source/texk/web2c/luatexdir/pdf/pdftables.w
+++ b/source/texk/web2c/luatexdir/pdf/pdftables.w
@@ -58,11 +58,11 @@ static void avl_put_obj(PDF pdf, int t, oentry * oe)
     if (pdf->obj_tree[t] == NULL) {
         pdf->obj_tree[t] = avl_create(compare_info, NULL, &avl_xallocator);
         if (pdf->obj_tree[t] == NULL)
-            pdftex_fail("avlstuff.c: avl_create() pdf->obj_tree failed");
+            luatex_fail("avlstuff.c: avl_create() pdf->obj_tree failed");
     }
     pp = avl_probe(pdf->obj_tree[t], oe);
     if (pp == NULL)
-        pdftex_fail("avlstuff.c: avl_probe() out of memory in insertion");
+        luatex_fail("avlstuff.c: avl_probe() out of memory in insertion");
 }
 
 static void avl_put_int_obj(PDF pdf, int int0, int objptr, int t)
diff --git a/source/texk/web2c/luatexdir/ptexlib.h b/source/texk/web2c/luatexdir/ptexlib.h
index 011180baff6c3969b34f9ce06b6ef986ca21b92d..8b6f6ae66e7ca7a19354c4aa35ad3e79b16877e8 100644
--- a/source/texk/web2c/luatexdir/ptexlib.h
+++ b/source/texk/web2c/luatexdir/ptexlib.h
@@ -85,7 +85,7 @@ extern char **suffixlist;       /* in luainit.w */
 
 #  define check_buf(size, buf_size)                                 \
   if ((unsigned)(size) > (unsigned)(buf_size))                      \
-    pdftex_fail("buffer overflow: %d > %d at file %s, line %d",     \
+    luatex_fail("buffer overflow: %d > %d at file %s, line %d",     \
                 (int)(size), (int)(buf_size), __FILE__,  __LINE__ )
 
 #  define append_char_to_buf(c, p, buf, buf_size) do { \
diff --git a/source/texk/web2c/luatexdir/tex/texnodes.h b/source/texk/web2c/luatexdir/tex/texnodes.h
index fec5f65f418971d6da665e7565aa883c35d94556..330973968e136e8e057efda905499d8a7779314d 100644
--- a/source/texk/web2c/luatexdir/tex/texnodes.h
+++ b/source/texk/web2c/luatexdir/tex/texnodes.h
@@ -1,5 +1,5 @@
 /* texnodes.h
-   
+
    Copyright 2006-2008 Taco Hoekwater <taco@luatex.org>
 
    This file is part of LuaTeX.
@@ -146,7 +146,7 @@ typedef enum {
 #  define synctex_tag_glue(a)  vinfo((a)+3)
 #  define synctex_line_glue(a) vlink((a)+3)
 
-/* disc nodes could eventually be smaller, because the indirect 
+/* disc nodes could eventually be smaller, because the indirect
    pointers are not really needed (8 instead of 10).
  */
 
@@ -691,7 +691,7 @@ extern void print_short_node_contents(halfword n);
 extern void show_node_list(int i);
 extern pointer actual_box_width(pointer r, scaled base_width);
 
-/* TH: these two defines still need checking. The node ordering in luatex is not 
+/* TH: these two defines still need checking. The node ordering in luatex is not
    quite the same as in tex82 */
 
 #  define precedes_break(a) (type((a))<math_node && \
@@ -785,4 +785,9 @@ extern halfword new_skip_param(int n);
 extern halfword new_kern(scaled w);
 extern halfword new_penalty(int m);
 
+extern int lua_properties_enabled ;
+extern int lua_properties_level ;
+extern int lua_properties_use_metatable ;
+
 #endif
+
diff --git a/source/texk/web2c/luatexdir/tex/texnodes.w b/source/texk/web2c/luatexdir/tex/texnodes.w
index 9ce4138cdbf4058a375f8f45880d0b358ee98520..e205227459a1f2826a33e06936586122a946e827 100644
--- a/source/texk/web2c/luatexdir/tex/texnodes.w
+++ b/source/texk/web2c/luatexdir/tex/texnodes.w
@@ -334,6 +334,173 @@ node_info whatsit_node_data[] = {
 
 #define last_whatsit_node user_defined_node
 
+/* hh: experiment */
+
+/*
+
+When we copy a node list, there are several possibilities: we do the same as a new node,
+we copy the entry to the table in properties (a reference), we do a deep copy of a table
+in the properties, we create a new table and give it the original one as a metatable.
+After some experiments (that also included timing) with these scenarios I decided that a
+deep copy made no sense, nor did nilling. In the end both the shallow copy and the metatable
+variant were both ok, although the second ons is slower. The most important aspect to keep
+in mind is that references to other nodes in properties no longer can be valid for that
+copy. We could use two tables (one unique and one shared) or metatables but that only
+complicates matters.
+
+When defining a new node, we could already allocate a table but it is rather easy to do
+that at the lua end e.g. using a metatable __index method. That way it is under macro
+package control.
+
+When deleting a node, we could keep the slot (e.g. setting it to false) but it could make
+memory consumption raise unneeded when we have temporary large node lists and after that
+only small lists.
+
+So, in the end this is what we ended up with. For the record, I also experimented with the
+following:
+
+- copy attributes to the properties so that we hav efast access at the lua end: in the end
+  the overhead is not compensated by speed and convenience, in fact, attributes are not
+  that slow when it comes to accessing them
+- a bitset in the node but again the gain compared to attributes is neglectable and it also
+  demands a pretty string agreement over what bit represents what, and this is unlikely to
+  succeed in the tex community (I could use it for font handling, which is cross package,
+  but decided that it doesn't pay off
+
+In case one wonders why properties make sense then, well, it is not so much speed that we
+gain, but more convenience: storing all kind of (temporary) data in attributes is no fun and
+this mechanism makes sure that properties are cleaned up when a node is freed. Also, the
+advantage of a more or less global properties table is that we stay at the lua end. An
+alternative is to store a reference in the node itself but that is complicated by the fact
+that the register has some limitations (no numeric keys) and we also don't want to mess with
+it too much.
+
+*/
+
+int lua_properties_level         = 0 ; /* can be private */
+int lua_properties_enabled       = 0 ;
+int lua_properties_use_metatable = 0 ;
+
+/* We keep track of nesting so that we don't oveflow the stack, and, what is more important,
+don't keep resolving the registry index. */
+
+#define lua_properties_push do { \
+    if (lua_properties_enabled) { \
+        lua_properties_level = lua_properties_level + 1 ; \
+        if (lua_properties_level == 1) { \
+            lua_rawgeti(Luas, LUA_REGISTRYINDEX, luaS_index(node_properties)); \
+            lua_gettable(Luas, LUA_REGISTRYINDEX); \
+        } \
+    } \
+} while(0)
+
+#define lua_properties_pop do { \
+    if (lua_properties_enabled) { \
+        if (lua_properties_level == 1) \
+            lua_pop(Luas,1); \
+        lua_properties_level = lua_properties_level - 1 ; \
+    } \
+} while(0)
+
+/* No setting is needed: */
+
+#define lua_properties_set(target) do { \
+} while(0)
+
+/* Resetting boils down to nilling. */
+
+#define lua_properties_reset(target) do { \
+    if (lua_properties_enabled) { \
+        if (lua_properties_level == 0) { \
+            lua_rawgeti(Luas, LUA_REGISTRYINDEX, luaS_index(node_properties)); \
+            lua_gettable(Luas, LUA_REGISTRYINDEX); \
+            lua_pushnil(Luas); \
+            lua_rawseti(Luas,-2,target); \
+            lua_pop(Luas,1); \
+        } else { \
+            lua_pushnil(Luas); \
+            lua_rawseti(Luas,-2,target); \
+        } \
+    } \
+} while(0)
+
+/* For a moment I considered supporting all kind of data types but in practice
+that makes no sense. So we stick to a cheap shallow copy with as option a
+metatable. Btw, a deep copy would look like this:
+
+static void copy_lua_table(lua_State* L, int index) {
+    lua_newtable(L);
+    lua_pushnil(L);
+    while(lua_next(L, index-1) != 0) {
+        lua_pushvalue(L, -2);
+        lua_insert(L, -2);
+        if (lua_type(L,-1)==LUA_TTABLE)
+            copy_lua_table(L,-1);
+        lua_settable(L, -4);
+    }
+    lua_pop(L,1);
+}
+
+#define lua_properties_copy(target, source) do { \
+    if (lua_properties_enabled) { \
+        lua_pushnumber(Luas,source); \
+        lua_rawget(Luas,-2); \
+        if (lua_type(Luas,-1)==LUA_TTABLE) { \
+            copy_lua_table(Luas,-1); \
+            lua_pushnumber(Luas,target); \
+            lua_insert(Luas,-2); \
+            lua_rawset(Luas,-3); \
+        } else { \
+            lua_pop(Luas,1); \
+        } \
+    } \
+} while(0)
+
+*/
+
+/* isn't there a faster way to metatable? */
+
+#define lua_properties_copy(target,source) do { \
+    if (lua_properties_enabled) { \
+        if (lua_properties_level == 0) { \
+            lua_rawgeti(Luas, LUA_REGISTRYINDEX, luaS_index(node_properties)); \
+            lua_gettable(Luas, LUA_REGISTRYINDEX); \
+            lua_rawgeti(Luas,-1,source); \
+            if (lua_type(Luas,-1)==LUA_TTABLE) { \
+                if (lua_properties_use_metatable) { \
+                    lua_newtable(Luas); \
+                    lua_insert(Luas,-2); \
+                    lua_setfield(Luas,-2,"__index"); \
+                    lua_newtable(Luas); \
+                    lua_insert(Luas,-2); \
+                    lua_setmetatable(Luas,-2); \
+                } \
+                lua_rawseti(Luas,-2,target); \
+            } else { \
+                lua_pop(Luas,1); \
+            } \
+            lua_pop(Luas,1); \
+        } else { \
+            lua_rawgeti(Luas,-1,source); \
+            if (lua_type(Luas,-1)==LUA_TTABLE) { \
+                if (lua_properties_use_metatable) { \
+                    lua_newtable(Luas); \
+                    lua_insert(Luas,-2); \
+                    lua_setfield(Luas,-2,"__index"); \
+                    lua_newtable(Luas); \
+                    lua_insert(Luas,-2); \
+                    lua_setmetatable(Luas,-2); \
+                } \
+                lua_rawseti(Luas,-2,target); \
+            } else { \
+                lua_pop(Luas,1); \
+            } \
+        } \
+    } \
+} while(0)
+
+/* Here end the property handlers. */
+
 @ @c
 halfword new_node(int i, int j)
 {
@@ -408,7 +575,6 @@ halfword new_node(int i, int j)
         synctex_line_glue(n) = line;
         break;
     case kern_node:
-        /* synctex ignores implicit kerns */
         if (j != 0) {
             synctex_tag_kern(n) = cur_input.synctex_tag_field;
             synctex_line_kern(n) = line;
@@ -428,6 +594,7 @@ halfword new_node(int i, int j)
     /* take care of attributes */
     if (nodetype_has_attributes(i)) {
         build_attribute_list(n);
+        /* lua_properties_set */
     }
     type(n) = (quarterword) i;
     subtype(n) = (quarterword) j;
@@ -458,20 +625,23 @@ halfword new_glyph_node(void)
     type(n) = glyph_node;
     subtype(n) = 0;
     build_attribute_list(n);
+    /* lua_properties_set */
     return n;
 }
 
 
 @ makes a duplicate of the node list that starts at |p| and returns a
-   pointer to the new list 
+   pointer to the new list
 @c
 halfword do_copy_node_list(halfword p, halfword end)
 {
     halfword q = null;          /* previous position in new list */
     halfword h = null;          /* head of the list */
+    register halfword s ;
     copy_error_seen = 0;
+    lua_properties_push; /* saves stack and time */
     while (p != end) {
-        register halfword s = copy_node(p);
+        s = copy_node(p);
         if (h == null) {
             h = s;
         } else {
@@ -480,6 +650,7 @@ halfword do_copy_node_list(halfword p, halfword end)
         q = s;
         p = vlink(p);
     }
+    lua_properties_pop; /* saves stack and time */
     return h;
 }
 
@@ -488,7 +659,50 @@ halfword copy_node_list(halfword p)
     return do_copy_node_list(p, null);
 }
 
-@ make a dupe of a single node 
+/*  There is no gain in using a temp var:
+
+    #define copy_sub_list(target,source) do { \
+         l = source; \
+         if (l != null) { \
+             s = copy_node_list(l); \
+             target = s; \
+         } else { \
+             target = null; \
+         } \
+    } while (0)
+
+    #define copy_sub_node(target,source) do { \
+        l = source; \
+        if (l != null) { \
+            s = copy_node(l); \
+            target = s ; \
+        } else { \
+            target = null; \
+        } \
+    } while (0)
+
+    So we use:
+*/
+
+#define copy_sub_list(target,source) do { \
+     if (source != null) { \
+         s = do_copy_node_list(source, null); \
+         target = s; \
+     } else { \
+         target = null; \
+     } \
+ } while (0)
+
+#define copy_sub_node(target,source) do { \
+    if (source != null) { \
+        s = copy_node(source); \
+        target = s ; \
+    } else { \
+        target = null; \
+    } \
+} while (0)
+
+@ make a dupe of a single node
 @c
 halfword copy_node(const halfword p)
 {
@@ -506,7 +720,7 @@ halfword copy_node(const halfword p)
                   (sizeof(memory_word) * (unsigned) i));
 
     /* handle synctex extension */
-    switch (type(p)) {
+   switch (type(p)) {
     case math_node:
         synctex_tag_math(r) = cur_input.synctex_tag_field;
         synctex_line_math(r) = line;
@@ -516,38 +730,25 @@ halfword copy_node(const halfword p)
         synctex_line_kern(r) = line;
         break;
     }
-
     if (nodetype_has_attributes(type(p))) {
         add_node_attr_ref(node_attr(p));
-        alink(r) = null;        /* needs checking */
+        alink(r) = null;
+        lua_properties_copy(r,p);
     }
     vlink(r) = null;
 
-
     switch (type(p)) {
     case glyph_node:
-        s = copy_node_list(lig_ptr(p));
-        lig_ptr(r) = s;
+        copy_sub_list(lig_ptr(r),lig_ptr(p)) ;
         break;
     case glue_node:
         add_glue_ref(glue_ptr(p));
-        s = copy_node_list(leader_ptr(p));
-        leader_ptr(r) = s;
+        copy_sub_list(leader_ptr(r),leader_ptr(p)) ;
         break;
     case hlist_node:
     case vlist_node:
     case unset_node:
-        s = copy_node_list(list_ptr(p));
-        list_ptr(r) = s;
-        break;
-    case ins_node:
-        add_glue_ref(split_top_ptr(p));
-        s = copy_node_list(ins_ptr(p));
-        ins_ptr(r) = s;
-        break;
-    case margin_kern_node:
-        s = copy_node(margin_char(p));
-        margin_char(r) = s;
+        copy_sub_list(list_ptr(r),list_ptr(p)) ;
         break;
     case disc_node:
         pre_break(r) = pre_break_head(r);
@@ -578,63 +779,51 @@ halfword copy_node(const halfword p)
             assert(tlink_no_break(r) == null);
         }
         break;
+    case ins_node:
+        add_glue_ref(split_top_ptr(p));
+        copy_sub_list(ins_ptr(r),ins_ptr(p)) ;
+        break;
+    case margin_kern_node:
+        copy_sub_node(margin_char(r),margin_char(p));
+        break;
     case mark_node:
         add_token_ref(mark_ptr(p));
         break;
     case adjust_node:
-        s = copy_node_list(adjust_ptr(p));
-        adjust_ptr(r) = s;
+        copy_sub_list(adjust_ptr(r),adjust_ptr(p));
         break;
-
     case choice_node:
-        s = copy_node_list(display_mlist(p));
-        display_mlist(r) = s;
-        s = copy_node_list(text_mlist(p));
-        text_mlist(r) = s;
-        s = copy_node_list(script_mlist(p));
-        script_mlist(r) = s;
-        s = copy_node_list(script_script_mlist(p));
-        script_script_mlist(r) = s;
+        copy_sub_list(display_mlist(r),display_mlist(p)) ;
+        copy_sub_list(text_mlist(r),text_mlist(p)) ;
+        copy_sub_list(script_mlist(r),script_mlist(p)) ;
+        copy_sub_list(script_script_mlist(r),script_script_mlist(p)) ;
         break;
     case simple_noad:
     case radical_noad:
     case accent_noad:
-        s = copy_node_list(nucleus(p));
-        nucleus(r) = s;
-        s = copy_node_list(subscr(p));
-        subscr(r) = s;
-        s = copy_node_list(supscr(p));
-        supscr(r) = s;
+        copy_sub_list(nucleus(r),nucleus(p)) ;
+        copy_sub_list(subscr(r),subscr(p)) ;
+        copy_sub_list(supscr(r),supscr(p)) ;
         if (type(p) == accent_noad) {
-            s = copy_node_list(accent_chr(p));
-            accent_chr(r) = s;
-            s = copy_node_list(bot_accent_chr(p));
-            bot_accent_chr(r) = s;
+            copy_sub_list(accent_chr(r),accent_chr(p)) ;
+            copy_sub_list(bot_accent_chr(r),bot_accent_chr(p)) ;
         } else if (type(p) == radical_noad) {
-            s = copy_node(left_delimiter(p));
-            left_delimiter(r) = s;
-            s = copy_node_list(degree(p));
-            degree(r) = s;
+            copy_sub_node(left_delimiter(r),left_delimiter(p)) ;
+            copy_sub_list(degree(r),degree(p)) ;
         }
         break;
     case fence_noad:
-        s = copy_node(delimiter(p));
-        delimiter(r) = s;
+        copy_sub_node(delimiter(r),delimiter(p)) ;
         break;
     case sub_box_node:
     case sub_mlist_node:
-        s = copy_node_list(math_list(p));
-        math_list(r) = s;
+        copy_sub_list(math_list(r),math_list(p)) ;
         break;
     case fraction_noad:
-        s = copy_node_list(numerator(p));
-        numerator(r) = s;
-        s = copy_node_list(denominator(p));
-        denominator(r) = s;
-        s = copy_node(left_delimiter(p));
-        left_delimiter(r) = s;
-        s = copy_node(right_delimiter(p));
-        right_delimiter(r) = s;
+        copy_sub_list(numerator(r),numerator(p)) ;
+        copy_sub_list(denominator(r),denominator(p)) ;
+        copy_sub_node(left_delimiter(r),left_delimiter(p)) ;
+        copy_sub_node(right_delimiter(r),right_delimiter(p)) ;
         break;
     case glue_spec_node:
         glue_ref_count(r) = null;
@@ -880,6 +1069,33 @@ int copy_error(halfword p)
     return 0;
 }
 
+/* No gain in a helper:
+
+    #define free_sub_list(source) do { \
+        l = source; \
+        if (l != null) \
+            flush_node_list(l); \
+    } while (0)
+
+    #define free_sub_node(source) do { \
+        l = source; \
+        if (l != null) \
+            flush_node(l); \
+    } while (0)
+
+    So:
+
+*/
+
+#define free_sub_list(source) do { \
+    if (source != null) \
+        flush_node_list(source); \
+} while (0)
+
+#define free_sub_node(source) do { \
+    if (source != null) \
+        flush_node(source); \
+} while (0)
 
 @ @c
 void flush_node(halfword p)
@@ -897,11 +1113,29 @@ void flush_node(halfword p)
 
     switch (type(p)) {
     case glyph_node:
-        flush_node_list(lig_ptr(p));
+        free_sub_list(lig_ptr(p));
         break;
     case glue_node:
         delete_glue_ref(glue_ptr(p));
-        flush_node_list(leader_ptr(p));
+        free_sub_list(leader_ptr(p));
+        break;
+    case hlist_node:
+    case vlist_node:
+    case unset_node:
+        free_sub_list(list_ptr(p));
+        break;
+    case disc_node:
+        free_sub_list(vlink(pre_break(p)));
+        free_sub_list(vlink(post_break(p)));
+        free_sub_list(vlink(no_break(p)));
+// why not: free_sub_list(pre_break(p));
+// why not: free_sub_list(post_break(p));
+// why not: free_sub_list(no_break(p));
+        break;
+    case rule_node:
+    case kern_node:
+    case math_node:
+    case penalty_node:
         break;
     case glue_spec_node:
         /* this allows free-ing of lua-allocated glue specs */
@@ -914,20 +1148,6 @@ void flush_node(halfword p)
         }
         return ;
         break ;
-    case attribute_node:
-    case attribute_list_node:
-    case temp_node:
-    case rule_node:
-    case kern_node:
-    case math_node:
-    case penalty_node:
-        break;
-
-    case hlist_node:
-    case vlist_node:
-    case unset_node:
-        flush_node_list(list_ptr(p));
-        break;
     case whatsit_node:
         switch (subtype(p)) {
 
@@ -1039,38 +1259,33 @@ void flush_node(halfword p)
     case mark_node:
         delete_token_ref(mark_ptr(p));
         break;
-    case disc_node:
-        flush_node_list(vlink(pre_break(p)));
-        flush_node_list(vlink(post_break(p)));
-        flush_node_list(vlink(no_break(p)));
-        break;
     case adjust_node:
         flush_node_list(adjust_ptr(p));
         break;
     case style_node:           /* nothing to do */
         break;
     case choice_node:
-        flush_node_list(display_mlist(p));
-        flush_node_list(text_mlist(p));
-        flush_node_list(script_mlist(p));
-        flush_node_list(script_script_mlist(p));
+        free_sub_list(display_mlist(p));
+        free_sub_list(text_mlist(p));
+        free_sub_list(script_mlist(p));
+        free_sub_list(script_script_mlist(p));
         break;
     case simple_noad:
     case radical_noad:
     case accent_noad:
-        flush_node_list(nucleus(p));
-        flush_node_list(subscr(p));
-        flush_node_list(supscr(p));
+        free_sub_list(nucleus(p));
+        free_sub_list(subscr(p));
+        free_sub_list(supscr(p));
         if (type(p) == accent_noad) {
-            flush_node_list(accent_chr(p));
-            flush_node_list(bot_accent_chr(p));
+            free_sub_list(accent_chr(p));
+            free_sub_list(bot_accent_chr(p));
         } else if (type(p) == radical_noad) {
-            flush_node(left_delimiter(p));
-            flush_node_list(degree(p));
+            free_sub_node(left_delimiter(p));
+            free_sub_list(degree(p));
         }
         break;
     case fence_noad:
-        flush_node(delimiter(p));
+        free_sub_list(delimiter(p));
         break;
     case delim_node:           /* nothing to do */
     case math_char_node:
@@ -1078,16 +1293,16 @@ void flush_node(halfword p)
         break;
     case sub_box_node:
     case sub_mlist_node:
-        flush_node_list(math_list(p));
+        free_sub_list(math_list(p));
         break;
     case fraction_noad:
-        flush_node_list(numerator(p));
-        flush_node_list(denominator(p));
-        flush_node(left_delimiter(p));
-        flush_node(right_delimiter(p));
+        free_sub_list(numerator(p));
+        free_sub_list(denominator(p));
+        free_sub_node(left_delimiter(p));
+        free_sub_node(right_delimiter(p));
         break;
     case pseudo_file_node:
-        flush_node_list(pseudo_lines(p));
+        free_sub_list(pseudo_lines(p));
         break;
     case pseudo_line_node:
     case shape_node:
@@ -1107,14 +1322,19 @@ void flush_node(halfword p)
     case inserting_node:
     case split_up_node:
     case expr_node:
+    case attribute_node:
+    case attribute_list_node:
+    case temp_node:
         break;
     default:
         fprintf(stdout, "flush_node: type is %d\n", type(p));
         return;
 
     }
-    if (nodetype_has_attributes(type(p)))
+    if (nodetype_has_attributes(type(p))) {
         delete_attribute_ref(node_attr(p));
+        lua_properties_reset(p);
+    }
     free_node(p, get_node_size(type(p), subtype(p)));
     return;
 }
@@ -1128,12 +1348,13 @@ void flush_node_list(halfword pp)
         return;
     if (free_error(p))
         return;
-
+    lua_properties_push; /* saves stack and time */
     while (p != null) {
         register halfword q = vlink(p);
         flush_node(p);
         p = q;
     }
+    lua_properties_pop; /* saves stack and time */
 }
 
 @ @c
@@ -1423,7 +1644,7 @@ halfword get_node(int s)
 {
     register halfword r;
 #if 0
-    check_static_node_mem(); 
+    check_static_node_mem();
 #endif
     assert(s < MAX_CHAIN_SIZE);
 
@@ -2566,9 +2787,9 @@ static void show_whatsit_node(int p)
   clobbered or chosen at random.
 
 
-@ |str_room| need not be checked; see |show_box| 
+@ |str_room| need not be checked; see |show_box|
 
-@ Recursive calls on |show_node_list| therefore use the following pattern: 
+@ Recursive calls on |show_node_list| therefore use the following pattern:
 @c
 #define node_list_display(A) do {               \
     append_char('.');                           \
diff --git a/source/texk/web2c/luatexdir/utils/utils.w b/source/texk/web2c/luatexdir/utils/utils.w
index 788025e1fc3bdcd046bd0f5eef2bc27fc268110a..23c1b73c1801de91c2c711ea4fab3ff3a67d7116 100644
--- a/source/texk/web2c/luatexdir/utils/utils.w
+++ b/source/texk/web2c/luatexdir/utils/utils.w
@@ -48,7 +48,7 @@ static const char _svn_version[] =
 @ @c
 #define check_nprintf(size_get, size_want) \
     if ((unsigned)(size_get) >= (unsigned)(size_want)) \
-        pdftex_fail ("snprintf failed: file %s, line %d", __FILE__, __LINE__);
+        luatex_fail ("snprintf failed: file %s, line %d", __FILE__, __LINE__);
 
 char *cur_file_name = NULL;
 static char print_buf[PRINTF_BUF_SIZE];
@@ -114,7 +114,7 @@ void make_subset_tag(fd_entry * fd)
     aa = avl_probe(st_tree, fd->subset_tag);
     assert(aa != NULL);
     if (j > 2)
-        pdftex_warn
+        luatex_warn
             ("\nmake_subset_tag(): subset-tag collision, resolved in round %d.\n",
              j);
 }
@@ -131,7 +131,7 @@ void tex_printf(const char *fmt, ...)
     va_end(args);
 }
 
-@ |pdftex_fail| may be called when a buffer overflow has happened/is
+@ |luatex_fail| may be called when a buffer overflow has happened/is
    happening, therefore may not call mktexstring.  However, with the
    current implementation it appears that error messages are misleading,
    possibly because pool overflows are detected too late.
@@ -141,7 +141,7 @@ void tex_printf(const char *fmt, ...)
 
 @c
 __attribute__ ((noreturn, format(printf, 1, 2)))
-void pdftex_fail(const char *fmt, ...)
+void luatex_fail(const char *fmt, ...)
 {
     va_list args;
     va_start(args, fmt);
@@ -171,7 +171,7 @@ void pdftex_fail(const char *fmt, ...)
    pdftex.web!
 @c
 __attribute__ ((format(printf, 1, 2)))
-void pdftex_warn(const char *fmt, ...)
+void luatex_warn(const char *fmt, ...)
 {
     int old_selector = selector;
     va_list args;
@@ -192,7 +192,7 @@ void pdftex_warn(const char *fmt, ...)
 @ @c
 void garbage_warning(void)
 {
-    pdftex_warn("dangling objects discarded, no output file produced.");
+    luatex_warn("dangling objects discarded, no output file produced.");
     remove_pdffile(static_pdf);
 }
 
@@ -225,7 +225,7 @@ void make_pdftex_banner(void)
 size_t xfwrite(void *ptr, size_t size, size_t nmemb, FILE * stream)
 {
     if (fwrite(ptr, size, nmemb, stream) != nmemb)
-        pdftex_fail("fwrite() failed");
+        luatex_fail("fwrite() failed");
     return nmemb;
 }
 
@@ -233,7 +233,7 @@ size_t xfwrite(void *ptr, size_t size, size_t nmemb, FILE * stream)
 int xfflush(FILE * stream)
 {
     if (fflush(stream) != 0)
-        pdftex_fail("fflush() failed (%s)", strerror(errno));
+        luatex_fail("fflush() failed (%s)", strerror(errno));
     return 0;
 }
 
@@ -242,7 +242,7 @@ int xgetc(FILE * stream)
 {
     int c = getc(stream);
     if (c < 0 && c != EOF)
-        pdftex_fail("getc() failed (%s)", strerror(errno));
+        luatex_fail("getc() failed (%s)", strerror(errno));
     return c;
 }
 
@@ -251,7 +251,7 @@ int xputc(int c, FILE * stream)
 {
     int i = putc(c, stream);
     if (i < 0)
-        pdftex_fail("putc() failed (%s)", strerror(errno));
+        luatex_fail("putc() failed (%s)", strerror(errno));
     return i;
 }
 
@@ -264,7 +264,7 @@ scaled ext_xn_over_d(scaled x, scaled n, scaled d)
     else
         r -= 0.5;
     if (r >= (double) max_integer || r <= -(double) max_integer)
-        pdftex_warn("arithmetic: number too big");
+        luatex_warn("arithmetic: number too big");
     return (scaled) r;
 }
 
diff --git a/source/texk/web2c/mplibdir/lmplib.c b/source/texk/web2c/mplibdir/lmplib.c
index c821d3db75e0a65e21724a6763f04378ef77abf5..48849579637c767d066086bfbeb8aded518f3b6f 100644
--- a/source/texk/web2c/mplibdir/lmplib.c
+++ b/source/texk/web2c/mplibdir/lmplib.c
@@ -49,7 +49,7 @@ int luaopen_mplib(lua_State * L); /* forward */
 
 /* metatable identifiers and tests */
 
-#define MPLIB_METATABLE     "MPlib"
+#define MPLIB_METATABLE     "MPlib.meta"
 #define MPLIB_FIG_METATABLE "MPlib.fig"
 #define MPLIB_GR_METATABLE  "MPlib.gr"
 
diff --git a/source/texk/web2c/texmfmp.h b/source/texk/web2c/texmfmp.h
index 422fc5d44215e0f8ad1e99ab35250310a215b133..ed9b2c6365e498659747f1f2bb55a28efd046c07 100644
--- a/source/texk/web2c/texmfmp.h
+++ b/source/texk/web2c/texmfmp.h
@@ -114,7 +114,7 @@ extern int tfmtemp, texinputtype;
 /* pdfTeX routines also used for e-pTeX and e-upTeX */
 #if defined (pdfTeX) || defined (epTeX) || defined (eupTeX)
 extern char start_time_str[];
-extern void pdftex_fail(const char *fmt, ...);
+extern void luatex_fail(const char *fmt, ...);
 extern void initstarttime(void);
 extern char *makecstring(integer s);
 extern char *makecfilename(integer s);