Index: Singular/iparith.cc
===================================================================
--- Singular/iparith.cc	(revision 8f95fa5a16bb8841f4212fe2ecdf0604c8f45bf9)
+++ Singular/iparith.cc	(revision c20f9f3118a723a20bf51e6296fce23f2ee87a60)
@@ -4618,4 +4618,8 @@
 static BOOLEAN jjMEMORY(leftv res, leftv v)
 {
+  // clean out "_":
+  sLastPrinted.CleanUp();
+  memset(&sLastPrinted,0,sizeof(sleftv));
+  // collect all info:
   omUpdateInfo();
   switch(((int)(long)v->Data()))
Index: Singular/links/ssiLink.cc
===================================================================
--- Singular/links/ssiLink.cc	(revision 8f95fa5a16bb8841f4212fe2ecdf0604c8f45bf9)
+++ Singular/links/ssiLink.cc	(revision c20f9f3118a723a20bf51e6296fce23f2ee87a60)
@@ -333,5 +333,5 @@
 {
   ssiInfo *d=(ssiInfo*)l->data;
-  int Ll=lSize(dd);
+  int Ll=dd->nr;
   fprintf(d->f_write,"%d ",Ll+1);
   int i;
@@ -376,7 +376,7 @@
   l=s_readint(d->f_read);
   buf=(char*)omAlloc0(l+1);
-  int c =s_getc(d->f_read); /* skip ' '*/
-  int ll=s_readbytes(buf,l,d->f_read);
-  //if (ll!=l) printf("want %d, got %d bytes\n",l,ll);
+  int throwaway =s_getc(d->f_read); /* skip ' '*/
+  throwaway=s_readbytes(buf,l,d->f_read);
+  //if (throwaway!=l) printf("want %d, got %d bytes\n",l,throwaway);
   buf[l]='\0';
   return buf;
@@ -440,5 +440,9 @@
     cf=nFindCoeffByName(cf_name);
     if (cf==NULL)
-    { Werror("cannot find cf:%s",cf_name);return NULL;}
+    {
+      Werror("cannot find cf:%s",cf_name);
+      omFree(cf_name);
+      return NULL;
+    }
   }
   if (N!=0)
@@ -665,10 +669,10 @@
   int nr;
   nr=s_readint(d->f_read);
-  lists L=(lists)omAlloc(sizeof(*L));
+  lists L=(lists)omAlloc0Bin(slists_bin);
   L->Init(nr);
 
   int i;
   leftv v;
-  for(i=0;i<nr;i++)
+  for(i=0;i<=L->nr;i++)
   {
     v=ssiRead1(l);
@@ -717,6 +721,5 @@
 {
   ssiInfo *d=(ssiInfo*)l->data;
-  int throwaway;
-  throwaway=s_readint(d->f_read);
+  int throwaway=s_readint(d->f_read);
   char *name=ssiReadString(d);
   int tok;
@@ -732,4 +735,5 @@
     Werror("blackbox %s not found",name);
   }
+  omFree(name);
 }
 
@@ -748,5 +752,5 @@
   memcpy(res,tmp,sizeof(sleftv));
   memset(tmp,0,sizeof(sleftv));
-  omFreeSize(tmp,sizeof(sleftv));
+  omFreeBin(tmp,sleftv_bin);
   if (nr_of_attr>0)
   {
@@ -778,4 +782,5 @@
 
     SI_LINK_SET_OPEN_P(l, flag);
+    if(l->data!=NULL) omFreeSize(l->data,sizeof(ssiInfo));
     l->data=d;
     omFree(l->mode);
@@ -1237,5 +1242,5 @@
 {
   ssiInfo *d = (ssiInfo *)l->data;
-  leftv res=(leftv)omAlloc0(sizeof(sleftv));
+  leftv res=(leftv)omAlloc0Bin(sleftv_bin);
   int t=0;
   t=s_readint(d->f_read);
@@ -1267,5 +1272,9 @@
                ssiSetCurrRing(d->r);
              }
-             if (t==15) return ssiRead1(l);
+             if (t==15) // setring
+             {
+               omFreeBin(res,sleftv_bin);
+               return ssiRead1(l);
+             }
            }
            break;
@@ -1352,7 +1361,8 @@
                 si_opt_1=n98_o1;
                 si_opt_2=n98_o2;
+                omFreeBin(res,sleftv_bin);
                 return ssiRead1(l);
              }
-    case 99: ssiClose(l); m2_end(0);
+    case 99: omFreeBin(res,sleftv_bin); ssiClose(l); m2_end(0);
     case 0: if (s_iseof(d->f_read))
             {
@@ -1362,5 +1372,5 @@
             break;
     default: Werror("not implemented (t:%d)",t);
-             omFreeSize(res,sizeof(sleftv));
+             omFreeBin(res,sleftv_bin);
              res=NULL;
              break;
@@ -1376,5 +1386,5 @@
   return res;
 no_ring: WerrorS("no ring");
-  omFreeSize(res,sizeof(sleftv));
+  omFreeBin(res,sleftv_bin);
   return NULL;
 }
@@ -1785,4 +1795,5 @@
   sprintf(buf,"ssi:connect %s:%s",host,port);
   slInit(l, buf);
+  omFreeSize(buf,256);
   if (slOpen(l,SI_LINK_OPEN,NULL)) return 1;
   SI_LINK_SET_RW_OPEN_P(l);
Index: omalloc/omStats.c
===================================================================
--- omalloc/omStats.c	(revision 8f95fa5a16bb8841f4212fe2ecdf0604c8f45bf9)
+++ omalloc/omStats.c	(revision c20f9f3118a723a20bf51e6296fce23f2ee87a60)
@@ -46,5 +46,5 @@
 #endif
 
-  om_Info.UsedBytes = om_Info.UsedBytesMalloc + om_Info.UsedBytesFromValloc;
+  om_Info.UsedBytes = om_Info.UsedBytesMalloc + om_Info.UsedBytesFromValloc - om_Info.InternalUsedBytesMalloc;
   om_Info.AvailBytes = om_Info.AvailBytesMalloc + om_Info.AvailBytesFromValloc;
 
