--- xfaces-3.3.orig/Imakefile
+++ xfaces-3.3/Imakefile
@@ -65,7 +65,8 @@
 #	-DLOOKUP_DEBUG
 #
 #CDEBUGFLAGS= -Wall -g 
-#CDEBUGFLAGS= -g
+#CDEBUGFLAGS= -g 
+CDEBUGFLAGS= -O3
 
 #ifdef USE_XFACE
 XFACE_SRCS	= face_search_xface.c face_image_xface.c
--- xfaces-3.3.orig/XFaces.ad
+++ xfaces-3.3/XFaces.ad
@@ -72,7 +72,7 @@
 !
 
 XFaces.soundPath:	/usr/sounds:/usr/demo/SOUND/sounds
-XFaces.imagePath:	/usr/images
+XFaces.imagePath:	/usr/share/xfaces/images
 
 !
 !  This is where we look for sounds/images in the "faces" format.
@@ -100,7 +100,7 @@ XFaces.imagePath:	/usr/images
 ! image types are set in the imageTypes resource.
 !
 
-XFaces.facedbPath:	/usr/faces
+XFaces.facedbPath: /usr/share/picons/:/usr/share/picons/users:/usr/share/picons/domains:/usr/share/picons/unknown
 
 !
 !  Tell how many different annotations there are. We can support any number.
@@ -244,7 +244,7 @@ XFaces.fromField:	From:
 !
 
 weather.listCommand:	wx.faces wbc
-weather.facedbPath:	/usr/faces/weather
+weather.facedbPath:	/usr/lib/picon/weather
 weather.compressImages:	False
 weather.keepOrder:	True
 weather.shapeExtra:	False
@@ -300,9 +300,9 @@ XFaces.frame.Label.borderWidth:		2
 !
 
 XFaces.frame.Label.translations:	<Btn1Down>:PlaySounds()\n\
-					<Btn2Down>:CheckMail()\n\
+					<Btn2Up>:CheckMail()\n\
 					<Btn3Down>:RunCommands()
-XFaces.frame.translations:		<Btn2Down>:CheckMail()
+XFaces.frame.translations:		<Btn2Up>:CheckMail()
 
 
 !
--- xfaces-3.3.orig/face_image.c
+++ xfaces-3.3/face_image.c
@@ -204,15 +204,22 @@ FaceImageLoadInfo*	info;
     int			length;
     static char*	filename = NULL;
     static int		filename_length = 0;
-    
+
+    char                my_label[512];
     /*
      *    First see if we already have this image.
     */
+
     
     for (fi = TheImages; fi != NULL; fi = fi->next)
     {
 	if (strcmp(fi->file, file) == 0)
 	{
+	  if (info && info->item) {
+	    sprintf(my_label, "%s@%s", info->item->user, info->item->host);
+	    if (strcmp(fi->label, my_label))
+	      break;
+	  }
 	    /*
 	     * Yep!
 	    */
@@ -290,7 +297,6 @@ FaceImageLoadInfo*	info;
     /*
      *   Ok, create a face image struct.
     */
-    
     fi = FaceImageCreate(file, info->type, image_data);
     
     info->item->image = fi;
@@ -367,6 +373,11 @@ FaceSearchData*	data;
 	    break;
 	}
     }
+
+#ifdef FACEDB_DEBUG
+    if (found) 
+      fprintf(stderr, "FaceImageLoad: Reporting %s as found\n", file);
+#endif
     
     return found;
 }
--- xfaces-3.3.orig/face_image_xpm.c
+++ xfaces-3.3/face_image_xpm.c
@@ -476,7 +476,7 @@ void*	type_data;
 static FaceImageType FaceImageTypeXpm = 
 {
     "xpm",
-    FaceImageXpmRead,
+    FaceImageShapedXpmRead,
     FaceImageXpmFree,
     FaceImageXpmPixmap,
     FaceImageXpmShape,
--- xfaces-3.3.orig/face_search_facedb.c
+++ xfaces-3.3/face_search_facedb.c
@@ -483,6 +483,10 @@ FacedbInfo*	info;
     int			parts;
     char*		username;
     FacedbMap*		map;
+
+#ifdef FACEDB_DEBUG
+    fprintf(stderr, "facedb: searching in path %s\n", path);
+#endif
     
     if (buffer1 == NULL)
     {
@@ -535,7 +539,7 @@ FacedbInfo*	info;
 	*/
 	
 	FaceSearchFacedbMakeName(file, info, i, buffer1);
-	
+#ifndef FACE_FILES_ONLY
 	/*
 	 * Try to load this guy.
 	*/
@@ -550,7 +554,7 @@ FacedbInfo*	info;
 	    XtFree(hostdata);
 	    return 1;
 	}
-	
+#endif
 	/*
 	 *  try adding "/face" and see what we find.
 	*/
@@ -570,29 +574,12 @@ FacedbInfo*	info;
 	    return 1;
 	}
 	
-#if 0
-	/*
-	 *  Finally if we are looking for an image try "/48x48x1".
-	*/
-	
-	if (info->data->format == FormatImage)
-	{
-	    strcpy(tail, "/48x48x1");
-	    
-	    if (FaceSearchLoad(buffer1, info->item, info->data))
-	    {
-		XtFree((char*) host);
-		XtFree(hostdata);
-		return 1;
-	    }
-	}
-#endif
     }
     
     /*
      *   try for user in the MISC directory.
     */
-    
+#ifndef FACE_FILES_ONLY
     sprintf(buffer1, "%sMISC/%s", file, username);
     
 #ifdef FACEDB_DEBUG
@@ -605,7 +592,7 @@ FacedbInfo*	info;
 	XtFree(hostdata);
 	return 1;
     }
-    
+#endif
     sprintf(buffer1, "%sMISC/%s/face", file, username);
     
 #ifdef FACEDB_DEBUG
@@ -632,7 +619,7 @@ FacedbInfo*	info;
 	*/
 	
 	FaceSearchFacedbMakeName(file, info, i, buffer1);
-	
+#ifndef FACE_FILES_ONLY
 	/*
 	 * Try to load this guy.
 	*/
@@ -653,7 +640,7 @@ FacedbInfo*	info;
 	    
 	    return 1;
 	}
-	
+#endif
 	/*
 	 *  try adding "/face" and see what we find.
 	*/
@@ -679,23 +666,6 @@ FacedbInfo*	info;
 	    return 1;
 	}
 	
-#if 0
-	/*
-	 *  Finally if we are looking for an image try "/48x48x1".
-	*/
-	
-	if (info->data->format == FormatImage)
-	{
-	    strcpy(tail, "/48x48x1");
-	    
-	    if (FaceSearchLoad(buffer1, info->item, info->data))
-	    {
-		XtFree((char*) host);
-		XtFree(hostdata);
-		return 1;
-	    }
-	}
-#endif
     }
     
     XtFree((char*) host);
@@ -704,7 +674,7 @@ FacedbInfo*	info;
     /*
      *   One last try.  The MISC directory. Look for "unknown"
     */
-    
+#ifndef FACE_FILES_ONLY
     sprintf(buffer1, "%sMISC/unknown", file);
     
 #ifdef FACEDB_DEBUG
@@ -721,7 +691,7 @@ FacedbInfo*	info;
 	
 	return 1;
     }
-    
+#endif
     sprintf(buffer1, "%sMISC/unknown/face", file);
     
 #ifdef FACEDB_DEBUG
--- xfaces-3.3.orig/faces.h
+++ xfaces-3.3/faces.h
@@ -181,6 +181,7 @@ typedef struct _faces_resources
     int			pop_port;
     String		pop_auth_file;	/* login/passwd  for pop server */
     					/* (full path!) */
+    Boolean		pop_use_top;	/* whether to use TOP or RETR */
     String		image_path;     /* Where to find the images.        */
     char*		image_path_str;
     char**		image_paths;
--- xfaces-3.3.orig/mail_box.c
+++ xfaces-3.3/mail_box.c
@@ -138,7 +138,8 @@ MailBoxParse()
 	 *   We got a list of headers so skip the body.
 	*/
 	
-	MailBodySkip(content_length);
+	/*MailBodySkip(content_length);*/
+	MailBodySkip(content_length == -1 ? -1 : content_length+1);
 
 	/*
 	 *  If we used the content_length value then we should skip
--- xfaces-3.3.orig/mail_items.c
+++ xfaces-3.3/mail_items.c
@@ -351,9 +351,18 @@ void
 MailBoxClean()
 {
     MailItem *item;
-    
-    for (item = TheMailItems; item != NULL; item = item->next)
+    MailItem *next_item;
+   
+    for (item = TheMailItems; item != NULL; item = next_item)
     {
+	/*
+	 * Save item->next here because if MailItemFree() is called, it will
+	 * free item and we won't be able to access it after the call.
+	 * Found by phkmalloc. Philippe Charnier (charnier@xp11.frmug.org)
+	 * 11/96.
+	 */
+	next_item = item->next;
+
 	if (item->in_use == 0)
 	{
 	    MailItemFree(item);
@@ -651,6 +660,7 @@ char** annotations;
     {
 	item->prev = TheMailItemsTail;
 	item->prev->next = item;
+	TheMailItemsTail = item;
     }
     
     item->face = FaceDisplay(item);
--- xfaces-3.3.orig/main.c
+++ xfaces-3.3/main.c
@@ -124,7 +124,7 @@ static XtResource FacesResourcesList[] =
     },
     {
 	"spoolDir", "SpoolDir", XtRString, sizeof(String),
-	offset(spool_dir), XtRString, "/usr/spool/mail"
+	offset(spool_dir), XtRString, "/var/spool/mail"
     },
     {
 	"popHost", "PopHost", XtRString, sizeof(String),
@@ -139,6 +139,10 @@ static XtResource FacesResourcesList[] =
 	offset(pop_port), XtRString, "110"
     },
     {
+	"popTop", "popTop", XtRBoolean, sizeof(Boolean),
+	offset(pop_use_top), XtRBoolean, (caddr_t) &defTrue
+    },
+    {
 	"listCommand", "Command", XtRString, sizeof(String),
 	offset(list_command), XtRString, NULL
     },
@@ -328,6 +332,9 @@ static XrmOptionDescRec options[] =
     },
     {
 	"-pop", "popHost", XrmoptionSepArg, NULL
+    },
+    {
+	"-popretr", "popTop", XrmoptionNoArg, "False"
     }
 };
 
--- xfaces-3.3.orig/pop_check.c
+++ xfaces-3.3/pop_check.c
@@ -362,7 +362,14 @@ int item;
     fprintf(stderr, "PopRetr(%d)\n", item);
 #endif
     
-    fprintf(output, "RETR %d\r\n", item);
+    if (TheFacesResources.pop_use_top)
+    {
+    	fprintf(output, "TOP %d 0\r\n", item);
+    }
+    else
+    {
+    	fprintf(output, "RETR %d\r\n", item);
+    }
     
     if (!PopResponce())
     {
--- xfaces-3.3.orig/xfaces.man
+++ xfaces-3.3/xfaces.man
@@ -1,4 +1,4 @@
-.TH XFACES 1
+.TH XFACES 1x
 .SH NAME
 xfaces - mail image display for X
 .SH SYNOPSIS
@@ -75,6 +75,10 @@ than the tile size.
 .BI \-pop " <hostname>"
 This option specifies the host name to use for a POP3 mailbox.  Also
 available as \fBXFaces.popHost\fP.
+.TP 8
+.BI \-top
+For backwards compatibility, use the RETR POP3 command instead of TOP
+to check for new messages on the POP3 server.
 .SH X DEFAULTS
 The application class name is \fBXFaces\fP.  For best results the
 following \fBShell\fP resource is suggested:
@@ -188,6 +192,12 @@ type of authentication.
 This specifies what \fIport number\fP to use for POP.  The default is
 the standard POP3 port 110.
 .TP 8
+.BI XFaces.popTop: " <flag>"
+Specify whether or not to use the newer TOP POP3 command, rather than
+the RETR command (which may have the side-effect of marking the mail
+read on the POP3 server).  This also reduces the amount of network traffic
+to the POP3 server, so is enabled by default.
+.TP 8
 .BI XFaces.listCommand: <user command>
 This resource specifies a user command that will be executed instead
 of looking at the spool file. If this resource is specified then
@@ -289,7 +299,7 @@ of the \fIXFaces\fP main window to becom
 no image.  This defaults to \fITrue\fP.
 .TP 8
 .BI XFaces.useCommands: " <flag>"
-This resource tells \FIXFaces\fP if it needs to search for shell commands to
+This resource tells \fIXFaces\fP if it needs to search for shell commands to
 run in addition to image and sounds.  The default is \fIFalse\fP.
 .TP 8
 .BI XFaces.useContentLength: " <flag>"
@@ -318,7 +328,7 @@ types are attempted. Valid types are:
 .TP 8
 .B xpm-shaped
 This is a shaped color image.  Shaped xpm files should be named
-\fIface-shaped.xpm\fP.
+\fIface-shape.xpm\fP.
 .TP 8
 .B xpm
 This is a non shaped color image. These files should be named
@@ -357,7 +367,7 @@ search.  Each line is constructed as fol
 The \fI<format list>\fP is currently ignored for the \fBsoundSearch\fP
 resource. Both the \fI<format list>\fP and the <search path> are 
 (except if you use the \fIfacedb\fP search) for the \fBcommandSearch\fP
-resoiurce.  If the \fI<format list>\fP is empty then the list in the
+resource.  If the \fI<format list>\fP is empty then the list in the
 \fBimageFormats\fP resource is used.  If the \fI<search path>\fP is
 empty then the \fBfacedbPath\fP is used for \fIfacedb\fP searches for
 both sounds and images and one of the \fBsoundPath\fP or
