diff --git a/fallback.c b/fallback.c
index 2e40f973..c86d04cd 100644
--- a/fallback.c
+++ b/fallback.c
@@ -3,7 +3,7 @@
 ** TecCGraf - PUC-Rio
 */
  
-char *rcs_fallback="$Id: fallback.c,v 1.35 1997/03/31 14:17:09 roberto Exp roberto $";
+char *rcs_fallback="$Id: fallback.c,v 1.36 1997/03/31 20:59:09 roberto Exp roberto $";
 
 #include <stdio.h>
 #include <string.h>
@@ -18,21 +18,6 @@ char *rcs_fallback="$Id: fallback.c,v 1.35 1997/03/31 14:17:09 roberto Exp rober
 #include "hash.h"
 
 
-static char *typenames[] = { /* ORDER LUA_T */
-  "userdata", "line", "cmark", "mark", "function",
-  "function", "table", "string", "number", "nil",
-  NULL
-};
-
-
-void luaI_type (void)
-{
-  lua_Object o = lua_getparam(1);
-  luaL_arg_check(o != LUA_NOOBJECT, "type", 1, "no argument");
-  lua_pushstring(typenames[-ttype(luaI_Address(o))]);
-  lua_pushnumber(lua_tag(o));
-}
-
 
 /* -------------------------------------------
 ** Reference routines
@@ -136,7 +121,6 @@ static int luaI_checkevent (char *name, char *list[])
 
 
 static struct IM {
-  lua_Type tp;
   TObject int_method[IM_N];
 } *luaI_IMtable = NULL;
 
@@ -157,7 +141,7 @@ static char validevents[NUM_TYPES][IM_N] = { /* ORDER LUA_T, ORDER IM */
 };
 
 static int validevent (lua_Type t, int e)
-{
+{ /* ORDER LUA_T */
   return (t < LUA_T_NIL) ?  1 : validevents[-t][e];
 }
 
@@ -175,27 +159,19 @@ void luaI_initfallbacks (void)
     int i;
     IMtable_size = NUM_TYPES+10;
     luaI_IMtable = newvector(IMtable_size, struct IM);
-    for (i=LUA_T_NIL; i<=LUA_T_USERDATA; i++) {
-      luaI_IMtable[-i].tp = (lua_Type)i;
+    for (i=LUA_T_NIL; i<=LUA_T_USERDATA; i++)
       init_entry(i);
-    }
   }
 }
 
-int lua_newtag (char *t)
+int lua_newtag (void)
 {
-  int tp;
   --last_tag;
   if ((-last_tag) >= IMtable_size) {
     luaI_initfallbacks();
     IMtable_size = growvector(&luaI_IMtable, IMtable_size,
                               struct IM, memEM, MAX_INT);
   }
-  tp = -findstring(t, typenames);
-  if (tp == LUA_T_ARRAY || tp == LUA_T_USERDATA)
-    luaI_IMtable[-last_tag].tp = tp;
-  else
-    lua_error("invalid type for new tag");
   init_entry(last_tag);
   return last_tag;
 }
@@ -203,27 +179,28 @@ int lua_newtag (char *t)
 
 static void checktag (int tag)
 {
-  if (!(last_tag <= (tag) && (tag) <= 0))
+  if (!(last_tag <= tag && tag <= 0))
     lua_error("invalid tag");
 }
 
-lua_Type luaI_typetag (int tag)
+int luaI_userdatatag (int tag)
 {
-  if (tag >= 0) return LUA_T_USERDATA;
-  else {
-    checktag(tag);
-    return luaI_IMtable[-tag].tp;
-  }
+  return (tag >= 0 || (last_tag <= tag && tag < LUA_T_NIL));
 }
 
+
 void luaI_settag (int tag, TObject *o)
 {
-  if (ttype(o) != luaI_typetag(tag))
-    lua_error("Tag is not compatible with this type");
-  if (o->ttype == LUA_T_ARRAY)
-    o->value.a->htag = tag;
-  else  /* must be userdata */
-    o->value.ts->tag = tag;
+  switch (ttype(o)) {
+    case LUA_T_ARRAY:
+      o->value.a->htag = tag;
+      break;
+    case LUA_T_USERDATA:
+      o->value.ts->tag = tag;
+      break;
+    default:
+      lua_error("settag: cannot change tag of given object");
+  }
 }
 
 
diff --git a/fallback.h b/fallback.h
index be54006c..44341ca4 100644
--- a/fallback.h
+++ b/fallback.h
@@ -1,5 +1,5 @@
 /*
-** $Id: fallback.h,v 1.18 1997/03/31 14:02:58 roberto Exp roberto $
+** $Id: fallback.h,v 1.19 1997/03/31 20:59:09 roberto Exp roberto $
 */
  
 #ifndef fallback_h
@@ -45,9 +45,8 @@ void luaI_travlock (int (*fn)(TObject *));
 void luaI_invalidaterefs (void);
 char *luaI_travfallbacks (int (*fn)(TObject *));
 
-void luaI_type (void);
 void luaI_settag (int tag, TObject *o);
-lua_Type luaI_typetag (int tag);
+int luaI_userdatatag (int tag);
 TObject *luaI_getim (int tag, IMS event);
 #define luaI_getimbyObj(o,e)  (luaI_getim(luaI_tag(o),(e)))
 TObject *luaI_geterrorim (void);
diff --git a/lua.h b/lua.h
index 910ac158..bcc8213e 100644
--- a/lua.h
+++ b/lua.h
@@ -2,7 +2,7 @@
 ** LUA - Linguagem para Usuarios de Aplicacao
 ** Grupo de Tecnologia em Computacao Grafica
 ** TeCGraf - PUC-Rio
-** $Id: lua.h,v 3.39 1997/04/01 19:02:43 roberto Exp roberto $
+** $Id: lua.h,v 3.40 1997/04/02 17:44:18 roberto Exp roberto $
 */
 
 
@@ -23,7 +23,7 @@ lua_Object     lua_setfallback		(char *event, lua_CFunction fallback);
 void           lua_setintmethod	(int tag, char *event, lua_CFunction method);
 void           lua_seterrormethod (lua_CFunction method);
 
-int            lua_newtag		(char *t);
+int            lua_newtag		(void);
 void           lua_settag		(int tag); /* In: object */
 
 void           lua_error		(char *s);
diff --git a/opcode.c b/opcode.c
index be2be6a3..5bbfe609 100644
--- a/opcode.c
+++ b/opcode.c
@@ -3,7 +3,7 @@
 ** TecCGraf - PUC-Rio
 */
 
-char *rcs_opcode="$Id: opcode.c,v 3.90 1997/04/01 19:02:43 roberto Exp roberto $";
+char *rcs_opcode="$Id: opcode.c,v 3.91 1997/04/02 17:44:18 roberto Exp roberto $";
 
 #include <setjmp.h>
 #include <stdio.h>
@@ -987,6 +987,8 @@ void lua_pushbinarydata (void *buff, int size, int tag)
   if (buff == NULL)
     ttype(top) = LUA_T_NIL;
   else {
+    if (!luaI_userdatatag(tag))
+      lua_error("invalid tag for userdata");
     tsvalue(top) = luaI_createuserdata(buff, size, tag);
     ttype(top) = LUA_T_USERDATA;
   }
@@ -998,8 +1000,6 @@ void lua_pushbinarydata (void *buff, int size, int tag)
 */
 void lua_pushusertag (void *u, int tag)
 {
-  if (luaI_typetag(tag) != LUA_T_USERDATA)
-    lua_error("invalid tag in `lua_pushusertag'");
   lua_pushbinarydata(&u, sizeof(void *), tag);
 }