diff --git a/.gitattributes b/.gitattributes
index 77e2fb18727174b67eb154e78c5403aeecf295b2..a7f58e2c87b962cc12f2c464e92f08e431ea060c 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -624,7 +624,6 @@ testfont binary
 /src/modules/_Charset/charsetmod.h foreign_ident
 /src/modules/_Charset/configure.in foreign_ident
 /src/modules/_Charset/iso2022.c foreign_ident
-/src/modules/_Charset/iso2022.h foreign_ident
 /src/modules/_Charset/make_gb18030_h.pike foreign_ident
 /src/modules/_Charset/make_gbk_tables_h.pike foreign_ident
 /src/modules/_Charset/misc.c foreign_ident
diff --git a/src/modules/_Charset/charsetmod.c b/src/modules/_Charset/charsetmod.c
index df9813371b58034195ad5ec5ef4fb747cb30b4ce..1fbc53dc6b1849421e3e4a8e34d9a08da13118e0 100644
--- a/src/modules/_Charset/charsetmod.c
+++ b/src/modules/_Charset/charsetmod.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: charsetmod.c,v 1.67 2008/06/29 12:52:02 mast Exp $
+|| $Id: charsetmod.c,v 1.68 2008/06/29 13:54:59 mast Exp $
 */
 
 #ifdef HAVE_CONFIG_H
@@ -19,7 +19,6 @@
 #include "builtin_functions.h"
 
 #include "charsetmod.h"
-#include "iso2022.h"
 
 
 #define sp Pike_sp
@@ -31,8 +30,6 @@
 #define SIGNED
 #endif
 
-p_wchar1 *misc_charset_lookup(const char *name, int *rlo, int *rhi);
-
 static struct program *std_cs_program = NULL;
 static struct program *utf1_program = NULL, *utf1e_program = NULL;
 static struct program *utf7_program = NULL, *utf8_program = NULL;
@@ -709,8 +706,6 @@ static void f_feed_utf7(INT32 args)
 
 static ptrdiff_t feed_sjis(struct pike_string *str, struct std_cs_stor *s)
 {
-  extern UNICHAR map_JIS_C6226_1983[];
-
   const p_wchar0 *p = STR0(str);
   ptrdiff_t l = str->len;
   while(l>0) {
@@ -820,8 +815,6 @@ static void f_feed_euc(INT32 args)
 static void f_create_euc(INT32 args)
 {
   struct euc_stor *s = (struct euc_stor *)(fp->current_storage + euc_stor_offs);
-  extern struct charset_def charset_map[];
-  extern int num_charset_def;
   struct pike_string *str;
   int lo=0, hi=num_charset_def-1;
 
@@ -864,9 +857,8 @@ static void f_create_euc(INT32 args)
 
 static void f_create_multichar(INT32 args)
 {
-  extern struct multichar_def multichar_map[];
   char *name;
-  struct multichar_def *def = multichar_map;
+  const struct multichar_def *def = multichar_map;
   struct multichar_stor *s = (struct multichar_stor *)(fp->current_storage + multichar_stor_offs);
 
   get_all_args("create()", args, "%s", &name);
@@ -1210,7 +1202,6 @@ static void f_create_sjise(INT32 args)
 {
   struct std16e_stor *s = (struct std16e_stor *)(fp->current_storage + std16e_stor_offs);
   int i, j, z;
-  extern UNICHAR map_JIS_C6226_1983[];
 
   s->lowtrans = 0x5c;
   s->lo = 0x5c;
@@ -1252,8 +1243,6 @@ static void f_create_sjise(INT32 args)
 static void f_create_euce(INT32 args)
 {
   struct std16e_stor *s = (struct std16e_stor *)(fp->current_storage + std16e_stor_offs);
-  extern struct charset_def charset_map[];
-  extern int num_charset_def;
   struct pike_string *str;
   int i, j, z, lo=0, hi=num_charset_def-1;
   UNICHAR const *table=NULL;
@@ -1374,11 +1363,9 @@ static struct std16e_stor *push_std_16bite(int args, int allargs, int lo, int hi
 
 static void f_rfc1345(INT32 args)
 {
-  extern struct charset_def charset_map[];
-  extern int num_charset_def;
   struct pike_string *str;
   int lo=0, hi=num_charset_def-1;
-  p_wchar1 *tabl;
+  p_wchar1 const *tabl;
 
   check_all_args("rfc1345()", args, BIT_STRING, BIT_INT|BIT_VOID,
 		 BIT_STRING|BIT_VOID|BIT_INT, BIT_FUNCTION|BIT_VOID|BIT_INT,
@@ -2344,7 +2331,6 @@ PIKE_MODULE_INIT
 {
   int i;
   struct svalue prog;
-  extern void iso2022_init(void);
 
   iso2022_init();
 
@@ -2572,8 +2558,6 @@ PIKE_MODULE_INIT
 
 PIKE_MODULE_EXIT
 {
-  extern void iso2022_exit(void);
-
   if(utf7e_program != NULL)
     free_program(utf7e_program);
 
diff --git a/src/modules/_Charset/charsetmod.h b/src/modules/_Charset/charsetmod.h
index 9aa339e1e5600751a8f41716af3f448a77aa3d5e..66c68c422869eba9dadc816d1a40ab25788fccf0 100644
--- a/src/modules/_Charset/charsetmod.h
+++ b/src/modules/_Charset/charsetmod.h
@@ -2,12 +2,15 @@
 || 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: charsetmod.h,v 1.1 2008/06/29 12:52:03 mast Exp $
+|| $Id: charsetmod.h,v 1.2 2008/06/29 13:54:59 mast Exp $
 */
 
 #ifndef CHARSETMOD_H
 #define CHARSETMOD_H
 
+#include "global.h"
+#include "stralloc.h"
+
 static void DECLSPEC(noreturn) transcode_error_va (
   struct pike_string *str, ptrdiff_t pos, struct pike_string *charset,
   int encode, const char *reason, va_list args) ATTRIBUTE((noreturn));
@@ -21,4 +24,66 @@ void DECLSPEC(noreturn) transcode_error (
 void DECLSPEC(noreturn) transcoder_error (
   struct pike_string *str, ptrdiff_t pos, int encode, const char *reason, ...);
 
+typedef p_wchar1 UNICHAR;
+
+#define DEFCHAR (0xfffd)
+
+#define MODE_94   0
+#define MODE_96   1
+#define MODE_9494 2
+#define MODE_9696 3
+#define MODE_BIG5 4
+
+#define VARIANT_JP  1
+#define VARIANT_CN  2
+#define VARIANT_KR  3
+#define VARIANT_JP2 4
+
+struct charset_def {
+  const char *const name;
+  const UNICHAR *const table;
+  int mode;
+};
+
+struct real_charset_def {
+  const char *name;
+  p_wchar1 const * table;
+  const int lo, hi;
+};
+
+struct multichar_table {
+  const unsigned int lo;
+  const unsigned int hi;
+  const UNICHAR *const table;
+};
+
+struct multichar_def {
+  const char *const name;
+  const struct multichar_table *const table;
+};
+
+/* From misc.c */
+extern const UNICHAR map_ANSI_X3_110_1983[];
+extern const UNICHAR map_iso_ir_90[];
+extern const UNICHAR map_T_101_G2[];
+extern const UNICHAR map_T_61_8bit[];
+extern const UNICHAR map_videotex_suppl[];
+p_wchar1 const *misc_charset_lookup(const char *name, int *rlo, int *rhi);
+
+/* From tables.c */
+extern const UNICHAR map_ANSI_X3_4_1968[];
+extern const UNICHAR map_ISO_8859_1_1998[];
+extern const UNICHAR map_JIS_C6226_1983[];
+extern const UNICHAR * const iso2022_94[];
+extern const UNICHAR * const iso2022_96[];
+extern const UNICHAR * const iso2022_9494[];
+extern const UNICHAR * const iso2022_9696[];
+extern const struct multichar_def multichar_map[];
+extern const struct charset_def charset_map[];
+extern const int num_charset_def;
+
+/* From iso2022.c */
+void iso2022_init(void);
+void iso2022_exit(void);
+
 #endif	/* !CHARSETMOD_H */
diff --git a/src/modules/_Charset/iso2022.c b/src/modules/_Charset/iso2022.c
index d0966e566043c45aea51e6ec5cf722b1f3ee98f7..a87466c71a86e0860733fcee0c4210314d7b8469 100644
--- a/src/modules/_Charset/iso2022.c
+++ b/src/modules/_Charset/iso2022.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: iso2022.c,v 1.49 2008/06/29 12:52:03 mast Exp $
+|| $Id: iso2022.c,v 1.50 2008/06/29 13:54:59 mast Exp $
 */
 
 #ifdef HAVE_CONFIG_H
@@ -18,7 +18,6 @@
 #include "pike_error.h"
 
 #include "charsetmod.h"
-#include "iso2022.h"
 
 
 #define sp Pike_sp
@@ -58,10 +57,6 @@ struct iso2022enc_stor {
 
 #define EMIT(X) string_builder_putchar(&s->strbuild,(X))
 
-
-extern struct charset_def charset_map[];
-extern int num_charset_def;
-
 static const UNICHAR * const *transltab[4] = { iso2022_94, iso2022_96,
 					       iso2022_9494, iso2022_9696 };
 
@@ -717,8 +712,6 @@ static const unsigned INT32 jp2_tab[] = {
 static void eat_enc_string(struct pike_string *str, struct iso2022enc_stor *s,
 			   struct pike_string *rep, struct svalue *repcb)
 {
-  extern UNICHAR map_ANSI_X3_4_1968[];
-  extern UNICHAR map_ISO_8859_1_1998[];
   ptrdiff_t l = str->len;
   int s1 = 0;
 
@@ -1283,8 +1276,6 @@ static void f_drain(INT32 args)
 
 static void f_clear(INT32 args)
 {
-  extern UNICHAR map_ANSI_X3_4_1968[];
-  extern UNICHAR map_ISO_8859_1_1998[];
   struct iso2022_stor *s = (struct iso2022_stor *)fp->current_storage;
   int i;
 
@@ -1343,7 +1334,6 @@ static void f_enc_drain(INT32 args)
 
 static void f_enc_clear(INT32 args)
 {
-  extern UNICHAR map_ANSI_X3_4_1968[];
   struct iso2022enc_stor *s = (struct iso2022enc_stor *)fp->current_storage;
   int i;
 
diff --git a/src/modules/_Charset/iso2022.h b/src/modules/_Charset/iso2022.h
deleted file mode 100644
index dd6f8b6168a93a00a90ea68ccd4f0ae4a89c966a..0000000000000000000000000000000000000000
--- a/src/modules/_Charset/iso2022.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
-|| 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: iso2022.h,v 1.10 2006/01/05 23:04:00 nilsson Exp $
-*/
-
-#include "global.h"
-#include "stralloc.h"
-
-#ifndef NULL
-#define NULL (0)
-#endif
-
-typedef p_wchar1 UNICHAR;
-
-#define DEFCHAR (0xfffd)
-
-#define MODE_94   0
-#define MODE_96   1
-#define MODE_9494 2
-#define MODE_9696 3
-#define MODE_BIG5 4
-
-#define VARIANT_JP  1
-#define VARIANT_CN  2
-#define VARIANT_KR  3
-#define VARIANT_JP2 4
-
-struct charset_def {
-  const char *const name;
-  const UNICHAR *const table;
-  const int mode;
-};
-
-struct multichar_table {
-  const unsigned int lo;
-  const unsigned int hi;
-  const UNICHAR *const table;
-};
-
-struct multichar_def {
-  const char *const name;
-  const struct multichar_table *const table;
-};
-
-extern const UNICHAR * const iso2022_94[];
-extern const UNICHAR * const iso2022_96[];
-extern const UNICHAR * const iso2022_9494[];
-extern const UNICHAR * const iso2022_9696[];
-
diff --git a/src/modules/_Charset/misc.c b/src/modules/_Charset/misc.c
index bc9f2b2d96b75f118645c0f5d6731611cec70f11..bb5d5ba913624da2de39aba590a19f6f2e9ce7e3 100644
--- a/src/modules/_Charset/misc.c
+++ b/src/modules/_Charset/misc.c
@@ -2,10 +2,11 @@
 || 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: misc.c,v 1.21 2008/01/25 16:44:39 grubba Exp $
+|| $Id: misc.c,v 1.22 2008/06/29 13:54:59 mast Exp $
 */
 
 #include "global.h"
+#include "charsetmod.h"
 
 /* Note: See tables.c for how the private space is used. */
 
@@ -1935,7 +1936,7 @@ static const struct {
   const char *name;
   p_wchar1 const * table;
   const int lo, hi;
-} charset_map[] = {
+} misc_charset_map[] = {
   { "1026", map_IBM1026, 32, 255 },                                   /* :: ibm1026 */
   { "1250", map_windows_1250, 128, 255 },                             /* :: cp1250 */
   { "1251", map_windows_1251, 128, 255 },                             /* :: cp1251 */
@@ -2101,17 +2102,17 @@ static const struct {
   { "windows874", map_windows_874, 128, 255 },			      /* :: windows-874 */
   { "x0201", map_JIS_X0201, 92, 255 },                                /* :: x0201 */
 };
-#define NUM_CHARSETS (sizeof(charset_map)/sizeof(charset_map[0]))
+#define NUM_CHARSETS (sizeof(misc_charset_map)/sizeof(misc_charset_map[0]))
 
 p_wchar1 const *misc_charset_lookup(const char *name, int *rlo, int *rhi)
 {
   int lo=0, hi=NUM_CHARSETS-1;
   while(lo<=hi) {
     int c, mid = (lo+hi)>>1;
-    if((c = strcmp(name, charset_map[mid].name))==0) {
-      *rlo = charset_map[mid].lo;
-      *rhi = charset_map[mid].hi;
-      return charset_map[mid].table;
+    if((c = strcmp(name, misc_charset_map[mid].name))==0) {
+      *rlo = misc_charset_map[mid].lo;
+      *rhi = misc_charset_map[mid].hi;
+      return misc_charset_map[mid].table;
     }
     if(c<0)
       hi=mid-1;
diff --git a/src/modules/_Charset/tables.c b/src/modules/_Charset/tables.c
index 97523a85d14c61938372bda3509960beb665b656..2aeaf459055bc2b47750b435b1dce7d1148932d2 100644
--- a/src/modules/_Charset/tables.c
+++ b/src/modules/_Charset/tables.c
@@ -2,19 +2,13 @@
 || 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: tables.c,v 1.36 2007/06/25 17:48:59 grubba Exp $
+|| $Id: tables.c,v 1.37 2008/06/29 13:54:59 mast Exp $
 */
 
-#include "iso2022.h"
+#include "charsetmod.h"
 
 /* Updates can be found at http://www.itscj.ipsj.or.jp/ISO-IR/ */
 
-extern UNICHAR map_ANSI_X3_110_1983[];
-extern UNICHAR map_T_61_8bit[];
-extern UNICHAR map_T_101_G2[];
-extern UNICHAR map_iso_ir_90[];
-extern UNICHAR map_videotex_suppl[];
-
 /*
  * The private characters used by RFC1345 have been mapped as follows:
  *