diff --git a/src/modules/Image/colortable.c b/src/modules/Image/colortable.c
index 5c8a346ff2255fdefddda0f46c8732b541f96707..7ea34de328085e26183b87210504ba2b332f464f 100644
--- a/src/modules/Image/colortable.c
+++ b/src/modules/Image/colortable.c
@@ -1,11 +1,11 @@
 #include <config.h>
 
-/* $Id: colortable.c,v 1.22 1997/11/07 06:06:05 mirar Exp $ */
+/* $Id: colortable.c,v 1.23 1997/11/07 16:37:48 mirar Exp $ */
 
 /*
 **! module Image
 **! note
-**!	$Id: colortable.c,v 1.22 1997/11/07 06:06:05 mirar Exp $
+**!	$Id: colortable.c,v 1.23 1997/11/07 16:37:48 mirar Exp $
 **! class colortable
 **!
 **!	This object keeps colortable information,
@@ -21,7 +21,7 @@
 #undef COLORTABLE_REDUCE_DEBUG
 
 #include "global.h"
-RCSID("$Id: colortable.c,v 1.22 1997/11/07 06:06:05 mirar Exp $");
+RCSID("$Id: colortable.c,v 1.23 1997/11/07 16:37:48 mirar Exp $");
 
 #include <sys/types.h>
 #include <sys/stat.h>
@@ -2028,6 +2028,10 @@ static void image_colortable_add(INT32 args)
 	       {
 		  THIS->u.flat=_img_get_flat_from_image(img,numcolors);
 		  THIS->type=NCT_FLAT;
+		  THIS->u.flat=
+		     _img_reduce_number_of_colors(THIS->u.flat,
+						  numcolors,
+						  THIS->spacefactor);
 	       }
 	    }
 	    else 
@@ -2124,7 +2128,7 @@ void image_colortable_reduce(INT32 args)
 
 void image_colortable_operator_plus(INT32 args)
 {
-   struct object *o;
+   struct object *o,*tmpo=NULL;
    struct neo_colortable *dest,*src;
 
    int i;
@@ -2135,22 +2139,29 @@ void image_colortable_operator_plus(INT32 args)
    dest=(struct neo_colortable*)get_storage(o,image_colortable_program);
 
    for (i=0; i<args; i++)
-      if (sp[i-args].type==T_OBJECT)
+   {
+      if (sp[i-args].type==T_OBJECT &&
+	  (src=(struct neo_colortable*)
+	   get_storage(sp[i-args].u.object,image_colortable_program)))
       {
-	 src=(struct neo_colortable*)
-	    get_storage(sp[i-args].u.object,image_colortable_program);
-	 if (!src) 
-	 { 
-	    free_object(o); 
-	    error("Illegal argument %d to Image.colortable->`+",i+2); 
-	 }
-	 _img_add_colortable(dest,src);
+	 tmpo=NULL;
       }
-      else 
-      { 
-	 free_object(o); 
-	 error("Illegal argument %d to Image.colortable->`+",i+2); 
+      else if (sp[i-args].type==T_ARRAY ||
+	       sp[i-args].type==T_OBJECT)
+      {
+	 struct svalue *sv=sp+i-args;
+	 push_svalue(sv);
+	 tmpo=clone_object(image_colortable_program,1);
+	 src=(struct neo_colortable*)
+	   get_storage(tmpo,image_colortable_program);
+	 if (!src) abort();
       }
+      else error("Image-colortable->`+: Illegal argument %d\n",i+2);
+    
+      _img_add_colortable(dest,src);
+      
+      if (tmpo) free_object(tmpo);
+   }
    pop_n_elems(args);
    push_object(o);
 }
diff --git a/src/modules/Image/doc/Image.html b/src/modules/Image/doc/Image.html
index 047965f5fb2e874263f5c5c182f0cd6ec7e076e9..f8825ddb5aceb417de3f169b881589b7a0cdf28f 100644
--- a/src/modules/Image/doc/Image.html
+++ b/src/modules/Image/doc/Image.html
@@ -30,23 +30,23 @@ This module adds image-drawing and -manipulating
 <h4>NOTE</h4>
 <blockquote>
 <font size=-1><pre>file versions:
-     $Id: Image.html,v 1.13 1997/11/07 06:12:17 mirar Exp $
-     $Id: Image.html,v 1.13 1997/11/07 06:12:17 mirar Exp $
-     $Id: Image.html,v 1.13 1997/11/07 06:12:17 mirar Exp $
-     $Id: Image.html,v 1.13 1997/11/07 06:12:17 mirar Exp $
-     $Id: Image.html,v 1.13 1997/11/07 06:12:17 mirar Exp $
-     $Id: Image.html,v 1.13 1997/11/07 06:12:17 mirar Exp $
-     $Id: Image.html,v 1.13 1997/11/07 06:12:17 mirar Exp $
-     $Id: Image.html,v 1.13 1997/11/07 06:12:17 mirar Exp $
-     $Id: Image.html,v 1.13 1997/11/07 06:12:17 mirar Exp $
-     $Id: Image.html,v 1.13 1997/11/07 06:12:17 mirar Exp $
-     $Id: Image.html,v 1.13 1997/11/07 06:12:17 mirar Exp $
-     $Id: Image.html,v 1.13 1997/11/07 06:12:17 mirar Exp $
-     $Id: Image.html,v 1.13 1997/11/07 06:12:17 mirar Exp $
-     $Id: Image.html,v 1.13 1997/11/07 06:12:17 mirar Exp $
-     $Id: Image.html,v 1.13 1997/11/07 06:12:17 mirar Exp $
-     $Id: Image.html,v 1.13 1997/11/07 06:12:17 mirar Exp $
-     $Id: Image.html,v 1.13 1997/11/07 06:12:17 mirar Exp $
-     $Id: Image.html,v 1.13 1997/11/07 06:12:17 mirar Exp $
+     $Id: Image.html,v 1.14 1997/11/07 16:37:52 mirar Exp $
+     $Id: Image.html,v 1.14 1997/11/07 16:37:52 mirar Exp $
+     $Id: Image.html,v 1.14 1997/11/07 16:37:52 mirar Exp $
+     $Id: Image.html,v 1.14 1997/11/07 16:37:52 mirar Exp $
+     $Id: Image.html,v 1.14 1997/11/07 16:37:52 mirar Exp $
+     $Id: Image.html,v 1.14 1997/11/07 16:37:52 mirar Exp $
+     $Id: Image.html,v 1.14 1997/11/07 16:37:52 mirar Exp $
+     $Id: Image.html,v 1.14 1997/11/07 16:37:52 mirar Exp $
+     $Id: Image.html,v 1.14 1997/11/07 16:37:52 mirar Exp $
+     $Id: Image.html,v 1.14 1997/11/07 16:37:52 mirar Exp $
+     $Id: Image.html,v 1.14 1997/11/07 16:37:52 mirar Exp $
+     $Id: Image.html,v 1.14 1997/11/07 16:37:52 mirar Exp $
+     $Id: Image.html,v 1.14 1997/11/07 16:37:52 mirar Exp $
+     $Id: Image.html,v 1.14 1997/11/07 16:37:52 mirar Exp $
+     $Id: Image.html,v 1.14 1997/11/07 16:37:52 mirar Exp $
+     $Id: Image.html,v 1.14 1997/11/07 16:37:52 mirar Exp $
+     $Id: Image.html,v 1.14 1997/11/07 16:37:52 mirar Exp $
+     $Id: Image.html,v 1.14 1997/11/07 16:37:52 mirar Exp $
      </pre>
 </blockquote>
diff --git a/src/modules/Image/doc/Image.image.html b/src/modules/Image/doc/Image.image.html
index 34aff9b61f1dca03c3c50de24f3dbecdd6e11de5..2a1084a38434cac17762f452d30173cfb3e228aa 100644
--- a/src/modules/Image/doc/Image.image.html
+++ b/src/modules/Image/doc/Image.image.html
@@ -1035,105 +1035,10 @@ color of the requested pixel -- ({int red,int green,int blue})
 
 <hr>
 <a name=gif_add> </a>
+<a name=gif_add*> </a>
 <a name=gif_add_fs> </a>
 <a name=gif_add_fs_nomap> </a>
 <a name=gif_add_nomap> </a>
-<h4>SYNOPSIS</h4>
-<blockquote>
-<tt>string <b>gif_add</b>()<br>
-string <b>gif_add</b>(int&nbsp;x, int&nbsp;y)<br>
-string <b>gif_add</b>(int&nbsp;x, int&nbsp;y, int&nbsp;delay_cs)<br>
-string <b>gif_add</b>(int&nbsp;x, int&nbsp;y, float&nbsp;delay_s)<br>
-string <b>gif_add</b>(int&nbsp;x, int&nbsp;y, int&nbsp;num_colors, int&nbsp;delay_cs)<br>
-string <b>gif_add</b>(int&nbsp;x, int&nbsp;y, int&nbsp;num_colors, float&nbsp;delay_s)<br>
-string <b>gif_add</b>(int&nbsp;x, int&nbsp;y, array(array(int))&nbsp;colors, int&nbsp;delay_cs)<br>
-string <b>gif_add</b>(int&nbsp;x, int&nbsp;y, array(array(int))&nbsp;colors, float&nbsp;delay_s)<br>
-string <b>gif_add_fs</b>()<br>
-string <b>gif_add_fs</b>(int&nbsp;x, int&nbsp;y)<br>
-string <b>gif_add_fs</b>(int&nbsp;x, int&nbsp;y, int&nbsp;delay_cs)<br>
-string <b>gif_add_fs</b>(int&nbsp;x, int&nbsp;y, float&nbsp;delay_s)<br>
-string <b>gif_add_fs</b>(int&nbsp;x, int&nbsp;y, int&nbsp;num_colors, int&nbsp;delay_cs)<br>
-string <b>gif_add_fs</b>(int&nbsp;x, int&nbsp;y, int&nbsp;num_colors, float&nbsp;delay_s)<br>
-string <b>gif_add_fs</b>(int&nbsp;x, int&nbsp;y, array(array(int))&nbsp;colors, int&nbsp;delay_cs)<br>
-string <b>gif_add_fs</b>(int&nbsp;x, int&nbsp;y, array(array(int))&nbsp;colors, float&nbsp;delay_s)<br>
-string <b>gif_add_nomap</b>()<br>
-string <b>gif_add_nomap</b>(int&nbsp;x, int&nbsp;y)<br>
-string <b>gif_add_nomap</b>(int&nbsp;x, int&nbsp;y, int&nbsp;delay_cs)<br>
-string <b>gif_add_nomap</b>(int&nbsp;x, int&nbsp;y, float&nbsp;delay_s)<br>
-string <b>gif_add_nomap</b>(int&nbsp;x, int&nbsp;y, int&nbsp;num_colors, int&nbsp;delay_cs)<br>
-string <b>gif_add_nomap</b>(int&nbsp;x, int&nbsp;y, int&nbsp;num_colors, float&nbsp;delay_s)<br>
-string <b>gif_add_nomap</b>(int&nbsp;x, int&nbsp;y, array(array(int))&nbsp;colors, int&nbsp;delay_cs)<br>
-string <b>gif_add_nomap</b>(int&nbsp;x, int&nbsp;y, array(array(int))&nbsp;colors, float&nbsp;delay_s)<br>
-string <b>gif_add_fs_nomap</b>()<br>
-string <b>gif_add_fs_nomap</b>(int&nbsp;x, int&nbsp;y)<br>
-string <b>gif_add_fs_nomap</b>(int&nbsp;x, int&nbsp;y, int&nbsp;delay_cs)<br>
-string <b>gif_add_fs_nomap</b>(int&nbsp;x, int&nbsp;y, float&nbsp;delay_s)<br>
-string <b>gif_add_fs_nomap</b>(int&nbsp;x, int&nbsp;y, int&nbsp;num_colors, int&nbsp;delay_cs)<br>
-string <b>gif_add_fs_nomap</b>(int&nbsp;x, int&nbsp;y, int&nbsp;num_colors, float&nbsp;delay_s)<br>
-string <b>gif_add_fs_nomap</b>(int&nbsp;x, int&nbsp;y, array(array(int))&nbsp;colors, int&nbsp;delay_cs)<br>
-string <b>gif_add_fs_nomap</b>(int&nbsp;x, int&nbsp;y, array(array(int))&nbsp;colors, float&nbsp;delay_s, rgb_group&nbsp;*transparent)</tt>
-</blockquote>
-
-<h4>DESCRIPTION</h4>
-
-
-<blockquote>
-Makes a GIF (sub)image data chunk, to be placed 
-     at the given position. 
-
-<p>     The "fs" versions uses floyd-steinberg dithering, and the "nomap"
-     versions have no local colormap.
-
-<p>     Example: 
-     <pre>
-     object img1 = Image(200,200); 
-     object img2 = Image(200,200); 
-     // load img1 and img2 with stuff
-     write(img1->gif_begin()+
-           img1->gif_netscape_loop()+
-           img1->gif_add(0,0,100)+
-           img2->gif_add(0,0,100)+
-           img1->gif_end());
-     // voila, a gif animation...
-     </pre>
-</blockquote>
-<h4>ARGUMENTS</h4>
-<blockquote><dl>
-<dt><tt>int x</tt>
-<dt><tt>int y</tt>
-  <dd>the location of this subimage
-<dt><tt>int delay_cs</tt>
-  <dd>frame delay in centiseconds
-<dt><tt>float delay_s</tt>
-  <dd>frame delay in seconds
-<dt><tt>int num_colors</tt>
-  <dd>number of colors to quantize to (default is 256)
-<dt><tt>array array(array(int)) colors</tt>
-  <dd>colors to map to, format is ({({r,g,b}),({r,g,b}),...}).
-</dl></blockquote>
-<h4>RETURNS</h4>
-
-
-<blockquote>
-the GIF data chunk as a string
-</blockquote>
-
-
-<h4>NOTE</h4>
-<blockquote>
-I (Mirar) recommend reading about the GIF file format before 
-     experementing with these.
-</blockquote>
-
-
-<h4>SEE ALSO</h4>
-<blockquote>     <tt><a href=Image.image.html#gif_add>gif_add</a></tt>,
-     <tt><a href=Image.image.html#gif_end>gif_end</a></tt>,
-     <tt><a href=Image.image.html#gif_netscape_loop>gif_netscape_loop</a></tt>,
-     <tt><a href=Image.image.html#togif */>togif */</a></tt>
-</blockquote>
-
-<hr>
 <a name=gif_begin> </a>
 <a name=gif_end> </a>
 <a name=gif_netscape_loop> </a>
@@ -1153,7 +1058,15 @@ string <b>togif</b>(array(array(int))&nbsp;colors, int&nbsp;trans_r, int&nbsp;tr
 string <b>togif_fs</b>()<br>
 string <b>togif_fs</b>(int&nbsp;trans_r, int&nbsp;trans_g, int&nbsp;trans_b)<br>
 string <b>togif_fs</b>(int&nbsp;num_colors, int&nbsp;trans_r, int&nbsp;trans_g, int&nbsp;trans_b)<br>
-string <b>togif_fs</b>(array(array(int))&nbsp;colors, int&nbsp;trans_r, int&nbsp;trans_g, int&nbsp;trans_b)</tt>
+string <b>togif_fs</b>(array(array(int))&nbsp;colors, int&nbsp;trans_r, int&nbsp;trans_g, int&nbsp;trans_b)<br>
+string <b>gif_add</b>()<br>
+string <b>gif_add_fs</b>()<br>
+string <b>gif_add_nomap</b>()<br>
+string <b>gif_add_fs_nomap</b>()<br>
+string <b>gif_add*</b>(int&nbsp;x, int&nbsp;y)<br>
+string <b>gif_add*</b>(int&nbsp;x, int&nbsp;y, int&nbsp;delay_cs)<br>
+string <b>gif_add*</b>(int&nbsp;x, int&nbsp;y, int&nbsp;num_colors, int&nbsp;delay_cs)<br>
+string <b>gif_add*</b>(int&nbsp;x, int&nbsp;y, array(array(int))&nbsp;colors, int&nbsp;delay_cs)</tt>
 </blockquote>
 
 <h4>DESCRIPTION</h4>
@@ -1170,10 +1083,16 @@ old GIF API compatibility function. Don't use
      <tr><td>gif_netscape_loop</td><td><tt><a href=Image.GIF.netscape_loop_block.html>Image.GIF.netscape_loop_block</a></tt></td></tr>
      <tr><td>togif</td><td><tt><a href=Image.GIF.encode.html>Image.GIF.encode</a></tt></td></tr>
      <tr><td>togif_fs</td><td><tt><a href=Image.GIF.encode.html>Image.GIF.encode</a></tt>¹</td></tr>
+     <tr><td>gif_add</td><td><tt><a href=Image.GIF.render_block.html>Image.GIF.render_block</a></tt>¹²</td></tr>
+     <tr><td>gif_add_fs</td><td><tt><a href=Image.GIF.render_block.html>Image.GIF.render_block</a></tt>¹</td></tr>
+     <tr><td>gif_add_nomap</td><td><tt><a href=Image.GIF.render_block.html>Image.GIF.render_block</a></tt>²</td></tr>
+     <tr><td>gif_add_fs_nomap</td><td><tt><a href=Image.GIF.render_block.html>Image.GIF.render_block</a></tt>¹²</td></tr>
      </table>
 
 <p>     ¹ Use <tt><a href=Image.colortable.html>Image.colortable</a></tt> to get whatever dithering
      you want.
+
+<p>     ² local map toggle is sent as an argument
 </blockquote>
 <h4>RETURNS</h4>
 
diff --git a/src/modules/Image/encodings/gif.c b/src/modules/Image/encodings/gif.c
index eeb30fd2703880bdd298e0035e20db365dac94f3..dc822e38c7b4a3d1ea3e548716eb8f0ccb0a4a55 100644
--- a/src/modules/Image/encodings/gif.c
+++ b/src/modules/Image/encodings/gif.c
@@ -1,9 +1,9 @@
-/* $Id: gif.c,v 1.13 1997/11/07 06:06:20 mirar Exp $ */
+/* $Id: gif.c,v 1.14 1997/11/07 16:37:55 mirar Exp $ */
 
 /*
 **! module Image
 **! note
-**!	$Id: gif.c,v 1.13 1997/11/07 06:06:20 mirar Exp $
+**!	$Id: gif.c,v 1.14 1997/11/07 16:37:55 mirar Exp $
 **! submodule GIF
 **!
 **!	This submodule keep the GIF encode/decode capabilities
@@ -31,7 +31,7 @@
 
 #include "stralloc.h"
 #include "global.h"
-RCSID("$Id: gif.c,v 1.13 1997/11/07 06:06:20 mirar Exp $");
+RCSID("$Id: gif.c,v 1.14 1997/11/07 16:37:55 mirar Exp $");
 #include "pike_macros.h"
 #include "object.h"
 #include "constants.h"
@@ -674,7 +674,7 @@ CHRONO("gif render_block begin");
    if (numcolors==0)
       error("Image.GIF.render_block(): no colors in colortable\n");
    else if (numcolors>256)
-      error("Image.GIF.render_block(): too many colors in colortable (256 is max)\n");
+      error("Image.GIF.render_block(): too many colors in given colortable: %d (256 is max)\n",numcolors);
 
    if (args>=5)
    {
@@ -915,7 +915,7 @@ CHRONO("gif render_block end");
 **!	and is actually implemented that way.
 */
 
-static void _image_gif_encode(INT32 args,int fs)
+void _image_gif_encode(INT32 args,int fs)
 {
    struct image *img=NULL;
    struct object *imgobj=NULL;
diff --git a/src/modules/Image/image.c b/src/modules/Image/image.c
index 7e62c5f4e251b2d8142b1121cf8460aa1cd6cfa9..62f1e291b73aa506733bc021ab88b1be28d43789 100644
--- a/src/modules/Image/image.c
+++ b/src/modules/Image/image.c
@@ -1,9 +1,9 @@
-/* $Id: image.c,v 1.52 1997/11/07 06:06:10 mirar Exp $ */
+/* $Id: image.c,v 1.53 1997/11/07 16:37:50 mirar Exp $ */
 
 /*
 **! module Image
 **! note
-**!	$Id: image.c,v 1.52 1997/11/07 06:06:10 mirar Exp $
+**!	$Id: image.c,v 1.53 1997/11/07 16:37:50 mirar Exp $
 **! class image
 **!
 **!	The main object of the <ref>Image</ref> module, this object
@@ -84,7 +84,7 @@
 
 #include "stralloc.h"
 #include "global.h"
-RCSID("$Id: image.c,v 1.52 1997/11/07 06:06:10 mirar Exp $");
+RCSID("$Id: image.c,v 1.53 1997/11/07 16:37:50 mirar Exp $");
 #include "pike_macros.h"
 #include "object.h"
 #include "constants.h"
@@ -2454,8 +2454,8 @@ void image_map_compat(INT32 args) /* compat function */
 
   THREADS_DISALLOW();
 
-  free_object(o);
-  push_object(co);
+  free_object(co);
+  push_object(o);
 }
 
 void image_select_colors(INT32 args)
diff --git a/src/modules/Image/togif.c b/src/modules/Image/togif.c
index 9e878c69a00503c77341859688ed3ff7cdc228dc..38acdca2150ef22269b6805ca056893c11ccf912 100644
--- a/src/modules/Image/togif.c
+++ b/src/modules/Image/togif.c
@@ -2,7 +2,7 @@
 
 togif 
 
-$Id: togif.c,v 1.23 1997/11/07 07:20:48 mirar Exp $ 
+$Id: togif.c,v 1.24 1997/11/07 16:37:51 mirar Exp $ 
 
 old GIF API compat stuff
 
@@ -11,7 +11,7 @@ old GIF API compat stuff
 /*
 **! module Image
 **! note
-**!	$Id: togif.c,v 1.23 1997/11/07 07:20:48 mirar Exp $
+**!	$Id: togif.c,v 1.24 1997/11/07 16:37:51 mirar Exp $
 **! class image
 */
 
@@ -181,7 +181,7 @@ static void img_gif_add(INT32 args,int fs,int lm,
    {
       THISOBJ->refs++;
       push_object(THISOBJ);
-      push_int(256);
+      push_int(255);
       ncto=clone_object(image_colortable_program,2);
    }
 
@@ -259,36 +259,47 @@ void image_gif_add_fs_nomap(INT32 args)
 **! see also: gif_begin, gif_add, gif_end, toppm, fromgif
 */
 
+extern void _image_gif_encode(INT32 args,int fs);
 
 static void img_encode_gif(rgb_group *transparent,int fs,INT32 args)
 {
-  struct svalue sv;
-
-  /* on stack is now:
-     - eventual colortable instruction (number or array) */
-
-  /* (swap in) arguments to gif_add, x and y position */
-  push_int(0); if (args) { sv=sp[-1]; sp[-1]=sp[-2]; sp[-2]=sv; }
-  push_int(0); if (args) { sv=sp[-1]; sp[-1]=sp[-2]; sp[-2]=sv; }
-
-  img_gif_add(args+2,fs,1,transparent);
-  image_gif_begin(0);
-
-  /* on stack is now:
-     - gif image chunk with local palette 
-     - gif beginning */
-
-  /* swap them... */
-  sv=sp[-1]; sp[-1]=sp[-2]; sp[-2]=sv;
-
-  image_gif_end(0);
-
-  /* on stack is now: 
-     - gif beginning
-     - image with local palette and eventual gce block
-     - gif end chunk */
-  
-  f_add(3);
+   struct object *co=NULL;
+   if (args)
+   {
+      if (sp[-args].type==T_OBJECT)
+      {
+	 (co=sp[-args].u.object)->refs++;
+	 pop_n_elems(args);
+      }
+      else if (sp[-args].type==T_ARRAY)
+	 co=clone_object(image_colortable_program,args);
+      else if (sp[-args].type==T_INT)
+      {
+	 unsigned long numcolors=sp[-args].u.integer;
+	 pop_n_elems(args);
+	 push_object(THISOBJ); THISOBJ->refs++;
+	 push_int(numcolors);
+	 co=clone_object(image_colortable_program,2);
+      }
+      else
+	 error("Illegal argument to img->togif()\n");
+   }
+   else
+   {
+      push_object(THISOBJ); THISOBJ->refs++;
+      push_int(256);
+      co=clone_object(image_colortable_program,2);
+   }
+   push_object(THISOBJ); THISOBJ->refs++;
+   push_object(co);
+   if (transparent)
+   {
+      push_int(transparent->r);
+      push_int(transparent->g);
+      push_int(transparent->b);
+      _image_gif_encode(5,fs);
+   }
+   else _image_gif_encode(2,fs);
 }
 
 static INLINE void getrgb(struct image *img,