diff --git a/.gitattributes b/.gitattributes
index 0ee787125c421364f9a8f980c6afa09d0f53b133..10f716d12b1b55e49ee140723bc8db4f32efd792 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -318,7 +318,6 @@ testfont binary
 /src/dynamic_buffer.h foreign_ident
 /src/dynamic_load.c foreign_ident
 /src/dynamic_load.h foreign_ident
-/src/encode.c foreign_ident
 /src/encode.h foreign_ident
 /src/error.c foreign_ident
 /src/errors.h foreign_ident
diff --git a/src/encode.c b/src/encode.c
index 31a41abd96de343866bdcd84b9219cc0ab5173de..ae66432b92e9f48d262944d8a131472193ba0bc4 100644
--- a/src/encode.c
+++ b/src/encode.c
@@ -2,7 +2,7 @@
 || This file is part of Pike. For copyright information see COPYRIGHT.
 || Pike is distributed under GPL, LGPL and MPL. See the file COPYING
 || for more information.
-|| $Id: encode.c,v 1.294 2010/07/01 11:25:18 grubba Exp $
+|| $Id$
 */
 
 #include "global.h"
@@ -39,7 +39,9 @@
 
 #ifdef ENCODE_DEBUG
 /* Pass a nonzero integer as the third arg to encode_value,
- * encode_value_canonic and decode_value to activate this debug. */
+ * encode_value_canonic and decode_value to activate this debug. It
+ * both enables debug messages and also lessens the pickyness to
+ * sort-of be able to decode programs with the wrong codec. */
 #define EDB(N,X) do { debug_malloc_touch(data); if (data->debug>=N) {X;} } while (0)
 #ifndef PIKE_DEBUG
 #error ENCODE_DEBUG requires PIKE_DEBUG
@@ -3196,11 +3198,18 @@ static void decode_value2(struct decode_data *data)
 
 	  decode_value2(data);
 	  push_compact_version();
-	  if(!is_eq(Pike_sp-1,Pike_sp-2))
+	  if(!is_eq(Pike_sp-1,Pike_sp-2)
+#ifdef ENCODE_DEBUG
+	     && !data->debug
+#endif
+	    )
 	    Pike_error("Cannot decode programs encoded with other pike version.\n");
 	  pop_n_elems(2);
 
-	  data->pickyness++;
+#ifdef ENCODE_DEBUG
+	  if (!data->debug)
+#endif
+	    data->pickyness++;
 
 	  debug_malloc_touch(p);
 	  decode_number(p->flags,data);
@@ -3238,7 +3247,10 @@ static void decode_value2(struct decode_data *data)
 	      p->parent=program_from_svalue(Pike_sp-1);
 	      break;
 	    default:
-	      decode_error(NULL, Pike_sp - 1, "Program decode failed. Got: ");
+	      if (data->pickyness)
+		decode_error(NULL, Pike_sp - 1, "Program decode failed. Got: ");
+	      p->parent = 0;
+	      break;
 	  }
 	  if(p->parent) {
 	    add_ref(p->parent);
@@ -3577,8 +3589,11 @@ static void decode_value2(struct decode_data *data)
 	      call_c_initializers(placeholder);
 	    }
 	  }
-	  
-	  data->pickyness--;
+
+#ifdef ENCODE_DEBUG
+	  if (!data->debug)
+#endif
+	    data->pickyness--;
 
 	  if(placeholder)
 	  {
@@ -3947,13 +3962,20 @@ static void decode_value2(struct decode_data *data)
 	  /* Check the version. */
 	  decode_value2(data);
 	  push_compact_version();
-	  if(!is_eq(Pike_sp-1,Pike_sp-2))
+	  if(!is_eq(Pike_sp-1,Pike_sp-2)
+#ifdef ENCODE_DEBUG
+	     && !data->debug
+#endif
+	    )
 	    Pike_error("Cannot decode programs encoded with other pike version.\n");
 	  pop_n_elems(2);
 
 	  debug_malloc_touch(p);
 
-	  data->pickyness++;
+#ifdef ENCODE_DEBUG
+	  if (!data->debug)
+#endif
+	    data->pickyness++;
 
 	  /* parent */
 	  decode_value2(data);
@@ -4101,23 +4123,25 @@ static void decode_value2(struct decode_data *data)
 	    decode_value2(data);
 	    switch(entry_type) {
 	    case ID_ENTRY_EFUN_CONSTANT:
-	      if ((Pike_sp[-1].type != T_FUNCTION) ||
-		  (Pike_sp[-1].subtype != FUNCTION_BUILTIN)) {
+	      if (((Pike_sp[-1].type != T_FUNCTION) ||
+		   (Pike_sp[-1].subtype != FUNCTION_BUILTIN)) &&
+		  data->pickyness) {
 		ref_push_program (p);
 		decode_error(Pike_sp - 1, Pike_sp - 2,
 			     "Expected efun constant: ");
 	      }
 	      break;
 	    case ID_ENTRY_TYPE_CONSTANT:
-	      if (Pike_sp[-1].type != T_TYPE) {
+	      if (Pike_sp[-1].type != T_TYPE && data->pickyness) {
 		ref_push_program (p);
 		decode_error(Pike_sp - 1, Pike_sp - 2,
 			     "Expected type constant: ");
 	      }
 	      break;
 	    default:
-	      Pike_error("Internal error: Unsupported early constant (%d)\n",
-			 entry_type);
+	      if (data->pickyness)
+		Pike_error("Internal error: Unsupported early constant (%d)\n",
+			   entry_type);
 	      break;
 	    }
 	    /* name */
@@ -4665,7 +4689,10 @@ static void decode_value2(struct decode_data *data)
 			e, get_name_of_type(constant->sval.type)));
 	  }
 
-	  data->pickyness--;
+#ifdef ENCODE_DEBUG
+	  if (!data->debug)
+#endif
+	    data->pickyness--;
 
 	  /* The program should be consistent now. */
 	  p->flags &= ~PROGRAM_AVOID_CHECK;