diff --git a/lib/modules/Crypto.pmod/testsuite.in b/lib/modules/Crypto.pmod/testsuite.in
index 6cbdb6f037cf40c273a1e2c92091edd9ca4d4746..1a3d84ec49bb2d636b3ae570e9ee5d2e4212c589 100644
--- a/lib/modules/Crypto.pmod/testsuite.in
+++ b/lib/modules/Crypto.pmod/testsuite.in
@@ -194,6 +194,10 @@ cond_resolv( Nettle.MD5_Info, [[
 	  "3aee29ca9ce057ebe49629afcc3fb51f")
   test_eq(S(Crypto.MD5()->update("f")->update("oo")->digest()),
 	  "acbd18db4cc2f85cedef654fccc4a4d8")
+
+  test_eval_error(Crypto.MD5.hash(Image.Image(5,5)))
+  dnl test_eval_error(Crypto.MD5.hash(Stdio.File()))
+  test_eval_error(Crypto.MD5.hash(Stdio.File("/dev/null")))
 ]])
 
 
diff --git a/src/post_modules/Nettle/hash.cmod b/src/post_modules/Nettle/hash.cmod
index 9acc76247535497bfb3f1dc31234de64c532ab37..277325c92e4ff5b208c58a88e4696ba9a1c48d35 100644
--- a/src/post_modules/Nettle/hash.cmod
+++ b/src/post_modules/Nettle/hash.cmod
@@ -48,9 +48,6 @@ werror(const char *format, ...)
 #define werror(x)
 #endif
 
-static struct program *Fd_ref_program = NULL;
-static struct program *Fd_program = NULL;
-
 /*! @module Nettle */
 
 /*! @class HashInfo
@@ -146,6 +143,19 @@ PIKECLASS HashInfo
     push_string(end_shared_string(out));
   }
 
+  int is_stdio_file(struct object *o)
+  {
+    struct program *p = o->prog;
+    INT32 i = p->num_inherits;
+    while( i-- )
+    {
+      if( p->inherits[i].prog->id == PROG_STDIO_FD_ID ||
+          p->inherits[i].prog->id == PROG_STDIO_FD_REF_ID )
+        return 1;
+    }
+    return 0;
+  }
+
   /*! @decl string(0..255) hash(Stdio.File file, void|int bytes)
    *!
    *!  Works as a (faster) shortcut for
@@ -175,35 +185,8 @@ PIKECLASS HashInfo
     if (!meta)
       Pike_error("HashInfo not properly initialized.\n");
 
-    /* Verify that the input is a Stdio.Fd or Stdio.Fd_ref */
-    if (!Fd_program)
-      {
-	push_text("files.Fd");
-	SAFE_APPLY_MASTER("resolv",1);
-	Fd_program = program_from_svalue(Pike_sp-1);
-	if (!Fd_program) {
-	  pop_stack();
-	  Pike_error("Unable to resolv files.Fd.\n");
-	}
-	add_ref(Fd_program);
-	pop_stack( );
-      }
-
-    if (!Fd_ref_program)
-      {
-	push_text("files.Fd_ref");
-	SAFE_APPLY_MASTER("resolv",1);
-	Fd_ref_program = program_from_svalue(Pike_sp-1);
-	if (!Fd_ref_program) {
-	  pop_stack();
-	  Pike_error("Unable to resolv files.Fd_ref.\n");
-	}
-	add_ref(Fd_ref_program);
-	pop_stack( );
-      }
-
-    if (!get_storage(in, Fd_program) && !get_storage(in, Fd_ref_program) )
-      Pike_error("Object not Fd or Fd_ref or subclass.\n");
+    if (!is_stdio_file(in))
+      Pike_error("Object not Fd or Fd_ref, or subclass.\n");
 
     safe_apply(in, "query_fd", 0);
     fd = Pike_sp[-1].u.integer;
@@ -642,12 +625,6 @@ void
 hash_exit(void)
 {
   werror("Nettle, hash exit\n");
-  if (Fd_program) {
-    free_program( Fd_program );
-  }
-  if (Fd_ref_program) {
-    free_program( Fd_ref_program );
-  }
   EXIT;
 }
 
diff --git a/src/post_modules/Shuffler/b_source_normal_file.c b/src/post_modules/Shuffler/b_source_normal_file.c
index 66b1935930702e6f74f6d67293fe83bf6af91e1b..6348e3c66815adab9dddee6d97be66d7707120e9 100644
--- a/src/post_modules/Shuffler/b_source_normal_file.c
+++ b/src/post_modules/Shuffler/b_source_normal_file.c
@@ -25,8 +25,6 @@
  * Argument: Stdio.File instance pointing to a normal file
  */
 
-static struct program *Fd_ref_program = NULL;
-
 struct fd_source
 {
   struct source s;
@@ -71,6 +69,19 @@ static void free_source( struct source *src )
   free_object(((struct fd_source *)src)->obj);
 }
 
+static int is_stdio_file(struct object *o)
+{
+  struct program *p = o->prog;
+  INT32 i = p->num_inherits;
+  while( i-- )
+  {
+    if( p->inherits[i].prog->id == PROG_STDIO_FD_ID ||
+        p->inherits[i].prog->id == PROG_STDIO_FD_REF_ID )
+      return 1;
+  }
+  return 0;
+}
+
 struct source *source_normal_file_make( struct svalue *s,
 					INT64 start, INT64 len )
 {
@@ -79,20 +90,7 @@ struct source *source_normal_file_make( struct svalue *s,
   if(TYPEOF(*s) != PIKE_T_OBJECT)
     return 0;
 
-  if (!Fd_ref_program)
-  {
-    push_text("files.Fd_ref");
-    SAFE_APPLY_MASTER("resolv",1);
-    Fd_ref_program = program_from_svalue(Pike_sp-1);
-    if (!Fd_ref_program) {
-      pop_stack();
-      return 0;
-    }
-    add_ref(Fd_ref_program);
-    pop_stack( );
-  }
-
-  if (!get_storage( s->u.object, Fd_ref_program ) )
+  if(!is_stdio_file(s->u.object))
     return 0;
 
   if (find_identifier("query_fd", s->u.object->prog) < 0)
@@ -143,9 +141,6 @@ fail:
 
 void source_normal_file_exit( )
 {
-  if (Fd_ref_program) {
-    free_program( Fd_ref_program );
-  }
 }
 
 void source_normal_file_init( )
diff --git a/src/post_modules/Shuffler/c_source_stream.c b/src/post_modules/Shuffler/c_source_stream.c
index 89ee5f0e64800b9ee1b4e4516957a2215178afa3..5c97b060bf245cced9b92619c021539e53057c21 100644
--- a/src/post_modules/Shuffler/c_source_stream.c
+++ b/src/post_modules/Shuffler/c_source_stream.c
@@ -27,8 +27,6 @@
  */
 
 
-static struct program *Fd_ref_program = NULL;
-
 struct fd_source
 {
   struct source s;
@@ -143,6 +141,19 @@ static void set_callback( struct source *src, void (*cb)( void *a ), void *a )
   s->when_data_cb_arg = a;;
 }
 
+static int is_stdio_file(struct object *o)
+{
+  struct program *p = o->prog;
+  INT32 i = p->num_inherits;
+  while( i-- )
+  {
+    if( p->inherits[i].prog->id == PROG_STDIO_FD_ID ||
+        p->inherits[i].prog->id == PROG_STDIO_FD_REF_ID )
+      return 1;
+  }
+  return 0;
+}
+
 struct source *source_stream_make( struct svalue *s,
 				   INT64 start, INT64 len )
 {
@@ -150,19 +161,7 @@ struct source *source_stream_make( struct svalue *s,
   if(TYPEOF(*s) != PIKE_T_OBJECT)
     return 0;
 
-  if (!Fd_ref_program) {
-    push_text("files.Fd_ref");
-    SAFE_APPLY_MASTER("resolv",1);
-    Fd_ref_program = program_from_svalue(Pike_sp-1);
-    if (!Fd_ref_program) {
-      pop_stack();
-      return 0;
-    }
-    add_ref(Fd_ref_program);
-    pop_stack( );
-  }
-
-  if (!get_storage( s->u.object, Fd_ref_program ) )
+  if(!is_stdio_file(s->u.object))
     return 0;
 
   if (find_identifier("query_fd", s->u.object->prog) < 0)
@@ -191,9 +190,6 @@ struct source *source_stream_make( struct svalue *s,
 
 void source_stream_exit( )
 {
-  if (Fd_ref_program) {
-    free_program( Fd_ref_program );
-  }
 }
 
 void source_stream_init( )