diff --git a/externals/creb/modules/bmatrix~.c b/externals/creb/modules/bmatrix~.c
index 05c726889c6677a786e9053c075227bcb25d65c4..90676b448407c79f3fdd98d185fcd459602225a7 100644
--- a/externals/creb/modules/bmatrix~.c
+++ b/externals/creb/modules/bmatrix~.c
@@ -49,7 +49,7 @@ static void matrix_load(t_matrix *x, t_symbol *s)
   if(s && s->s_name)
     {
       post("matrix: loading %s",s->s_name);
-      if(matrix = fopen(s->s_name, "r"))
+      if(matrix = sys_fopen(s->s_name, "r"))
 	{
 	  int n = x->x_ctl.c_order;
 	  fread(x->x_ctl.c_A, sizeof(t_float), n*n, matrix);
diff --git a/externals/cxc/ascwave.c b/externals/cxc/ascwave.c
index 22f85b8522136bec163a67e3064222d169d17710..4c9978a776fd67031b832e72958d967d80e08466 100644
--- a/externals/cxc/ascwave.c
+++ b/externals/cxc/ascwave.c
@@ -49,7 +49,7 @@ static void ascwave_open(t_ascwave *x, t_symbol *filename)
      post("ascwave: open");
      x->filename = filename;
      post("ascwave: filename = %s",x->filename->s_name);
-     if ((x->x_file = fopen(x->filename->s_name,"w")) < 0)
+     if ((x->x_file = sys_fopen(x->filename->s_name,"w")) < 0)
      {
 	  error("can't create %s",filename->s_name);
 	  return;
diff --git a/externals/earplug~/earplug~.c b/externals/earplug~/earplug~.c
index c53d3207a7295d1a7c6e8fff669197fc28ebdde9..a72d6dd5c333157bd3545c7400a50eb477567170 100644
--- a/externals/earplug~/earplug~.c
+++ b/externals/earplug~/earplug~.c
@@ -200,7 +200,7 @@ static void *earplug_new(t_floatarg azimArg, t_floatarg elevArg)
 				fscanf(fp, "%f %f ", &earplug_impulses[i][0][j], &earplug_impulses[i][1][j]);
             }
         }
-        fclose(fp) ;
+        sys_fclose(fp) ;
     }
     x->impulses = earplug_impulses;
     
diff --git a/externals/ext13/sfread.c b/externals/ext13/sfread.c
index 9d990a47b843d8135bc6e0795a72ae83c37d9ee3..caa467297b2d2da2dce35eacc3b844b13ffa6bd1 100644
--- a/externals/ext13/sfread.c
+++ b/externals/ext13/sfread.c
@@ -52,9 +52,9 @@ void sfread_open(t_sfread *x,t_symbol *filename)
      /* close the old file */
 
      if (x->x_mapaddr) munmap(x->x_mapaddr,x->x_size);
-     if (x->x_fd >= 0) close(x->x_fd);
+     if (x->x_fd >= 0) sys_close(x->x_fd);
 
-     if ((x->x_fd = open(fname,O_RDONLY)) < 0)
+     if ((x->x_fd = sys_open(fname,O_RDONLY)) < 0)
      {
 	  error("can't open %s",fname);
 	  return;
diff --git a/externals/ext13/sfwrite13~.c b/externals/ext13/sfwrite13~.c
index ecf4532ddb8ce1f232b9c29b0dd3d45bc41c2879..f35916c3715cd9eaf9a8e95e06350e86d4e1d62c 100644
--- a/externals/ext13/sfwrite13~.c
+++ b/externals/ext13/sfwrite13~.c
@@ -140,7 +140,7 @@ static void sfwrite13_close(t_sfwrite13 *x)
 	  sfwrite13_wave_setup(x,&w);
 	  lseek(x->x_file,0,SEEK_SET);
 	  write(x->x_file,&w,sizeof(w));
-	  close(x->x_file);
+	  sys_close(x->x_file);
      }
      x->x_file = -1;
 }
@@ -164,7 +164,7 @@ static void sfwrite13_open(t_sfwrite13 *x,t_symbol *filename)
 
      sfwrite13_close(x);
 
-     if ((x->x_file = open(fname,OPENPARAMS,0664)) < 0)
+     if ((x->x_file = sys_open(fname,OPENPARAMS,0664)) < 0)
      {
 	  error("can't create %s",fname);
 	  return;
diff --git a/externals/ggee/gui/.image.c.swp b/externals/ggee/gui/.image.c.swp
deleted file mode 100644
index a7e8f8fc4ce7668ff2b1f77e2e96e7a06db183d3..0000000000000000000000000000000000000000
Binary files a/externals/ggee/gui/.image.c.swp and /dev/null differ
diff --git a/externals/ggee/gui/image.c b/externals/ggee/gui/image.c
index 67795a1338229bc096b6f492603535c0206148b6..ae501c4323741cd9099f041a9352866455f14307 100644
--- a/externals/ggee/gui/image.c
+++ b/externals/ggee/gui/image.c
@@ -45,9 +45,9 @@ t_symbol *image_trytoopen(t_image* x)
     canvas_makefilename(glist_getcanvas(x->x_glist), x->x_fname->s_name,
         fname, FILENAME_MAX);
     // try to open the file
-    if (file = fopen(fname, "r"))
+    if (file = sys_fopen(fname, "r"))
     {
-        fclose(file);
+        sys_fclose(file);
         return gensym(fname);
     }
     else
diff --git a/externals/ggee/gui/state.c b/externals/ggee/gui/state.c
index 063b15f103ac51e30857b39315854a58072716ba..dd6cad366f59ff9d85c19578f9945df866598af6 100644
--- a/externals/ggee/gui/state.c
+++ b/externals/ggee/gui/state.c
@@ -90,7 +90,7 @@ void state_dosave(t_state *x)
      else
 	  sprintf(name,"%s%s.%d",dirstr,x->x_name->s_name,x->x_slot);
 
-     fp = fopen(name,"w");
+     fp = sys_fopen(name,"w");
      if (!fp) {
 	  post("state: unable to open %s",name);
 	  return;
@@ -151,7 +151,7 @@ void state_dosave(t_state *x)
      } while ((a = (t_text*)((t_gobj*)a)->g_next));
      post("state saved to: %s",name);
 
-     fclose(fp);
+     sys_fclose(fp);
 
 }
 
diff --git a/externals/ggee/other/vbap.c b/externals/ggee/other/vbap.c
index 57dae7b8e1fd3b1f23ad7f2a3877d9deaf36bf6f..cf3b4d90e5e3d28e09161d4b70336a7083ef56d3 100644
--- a/externals/ggee/other/vbap.c
+++ b/externals/ggee/other/vbap.c
@@ -122,7 +122,7 @@ static void *vbap_new(t_symbol* s)
      canvas_makefilename(canvas_getcurrent(),s->s_name,
                          fname,MAXPDSTRING);
 
-     if((fp=fopen(fname,"r"))==NULL){
+     if((fp=sys_fopen(fname,"r"))==NULL){
 	  post("vbap: Could not open loudspeaker data file %s\n",fname);
 	  x->opened = 0;
      }
@@ -130,7 +130,7 @@ static void *vbap_new(t_symbol* s)
 	  if (!read_ls_conf(x,fp))
 	       return NULL;
 	  x->opened = 1;
-	  fclose(fp);
+	  sys_fclose(fp);
      }
 
      x->lasttrip[0] = 0;
diff --git a/externals/ggee/signal/sfwrite~.c b/externals/ggee/signal/sfwrite~.c
index 1209572c5b344a6e878cbf7790c4c815c2fb0734..706094c4bb9205883eda2f8ba58ca7e5235f88ca 100644
--- a/externals/ggee/signal/sfwrite~.c
+++ b/externals/ggee/signal/sfwrite~.c
@@ -99,7 +99,7 @@ static void sfwrite_close(t_sfwrite *x)
 	  sfwrite_wave_setup(x,&w);
 	  lseek(x->x_file,0,SEEK_SET);
 	  write(x->x_file,&w,sizeof(w));
-	  close(x->x_file);
+	  sys_close(x->x_file);
      }
      x->x_file = -1;
 }
@@ -123,7 +123,7 @@ static void sfwrite_open(t_sfwrite *x,t_symbol *filename)
 
      sfwrite_close(x);
 
-     if ((x->x_file = open(fname,OPENPARAMS,0664)) < 0)
+     if ((x->x_file = sys_open(fname,OPENPARAMS,0664)) < 0)
      {
 	  error("can't create %s",fname);
 	  return;
diff --git a/externals/grh/adaptive/src/adaptive.c b/externals/grh/adaptive/src/adaptive.c
index 5c3b6515fe769e71de21a3c676ea3f92c6117eaa..02aae8b749e2653f11832366ee50e265a4a4d217 100644
--- a/externals/grh/adaptive/src/adaptive.c
+++ b/externals/grh/adaptive/src/adaptive.c
@@ -79,7 +79,7 @@ void adaptation_write(const char *filename, t_int N, t_float mu, t_float *c)
   int i;
 
   // open file
-  f = fopen(filename, "w");
+  f = sys_fopen(filename, "w");
   if(!f)
   {
     post("adaptive, save: error open file");
@@ -96,7 +96,7 @@ void adaptation_write(const char *filename, t_int N, t_float mu, t_float *c)
     fprintf(f, "%.30f\n", c[i]);
 
   // close file
-  if (f) fclose(f);
+  if (f) sys_fclose(f);
   post("adaptive, save: coefficients written to file");
 }
 
@@ -107,7 +107,7 @@ void adaptation_read(const char *filename, t_int *N, t_float *mu,
   int i, n=0;
 
   // open file
-  f = fopen(filename, "r");
+  f = sys_fopen(filename, "r");
   if(!f)
   {
     post("adaptive, open: error open file");
diff --git a/externals/iem/iemgui/src/iem_image.c b/externals/iem/iemgui/src/iem_image.c
index 52f8c6115caf95bb94b7389d30f3c281af3355b7..faec94671f2fa944065ae9d05c06bf087a3c9f8e 100644
--- a/externals/iem/iemgui/src/iem_image.c
+++ b/externals/iem/iemgui/src/iem_image.c
@@ -57,11 +57,11 @@ static t_symbol *iem_image_calc_size(t_iem_image *x)
   else
   {
     if(fd >= 0)
-      close(fd);
+      sys_close(fd);
     strcpy(namebuf, dirbuf);
     strcat(namebuf, "/");
     strcat(namebuf, namebufptr);
-    fh = fopen(namebuf, "r");
+    fh = sys_fopen(namebuf, "r");
     if(fh == NULL)
     {
       post("iem_image-ERROR: cannot open %s second time", namebuf);
@@ -76,7 +76,7 @@ static t_symbol *iem_image_calc_size(t_iem_image *x)
         x->x_gifsym = (t_symbol *)0;
         return((t_symbol *)0);
         };
-      fclose(fh);
+      sys_fclose(fh);
       c = (char *)buf;
       if((c[0] != 'G')||(c[1] != 'I')||(c[2] != 'F'))
       {
diff --git a/externals/iemlib/iem_mp3/src/mp3play~.c b/externals/iemlib/iem_mp3/src/mp3play~.c
index d4c342a442ee338513b978da06b562e04864337d..bab4089c09b59292bb58d23110e366f27ca83c0f 100644
--- a/externals/iemlib/iem_mp3/src/mp3play~.c
+++ b/externals/iemlib/iem_mp3/src/mp3play~.c
@@ -3174,7 +3174,7 @@ static void *mp3play_tilde_new(void)
 static void mp3play_tilde_cleanup(t_mp3play_tilde *x)
 {
     x->file_is_open = 0;
-    fclose(x->fh);
+    sys_fclose(x->fh);
     x->play_state = 0;
     x->mp3_out_index = 0;
     x->mp_is_init = 0;
@@ -3404,7 +3404,7 @@ static void mp3play_tilde_do_open(t_mp3play_tilde *x, char *str, int calc_it)
         strcat(completefilename, str);
       }
 
-  if((x->fh = fopen(completefilename, "rb")) == NULL)
+  if((x->fh = sys_fopen(completefilename, "rb")) == NULL)
   {
       post("mp3play-ERROR: cannot open %s", completefilename);
   }
@@ -3520,13 +3520,13 @@ static void mp3play_tilde_do_open(t_mp3play_tilde *x, char *str, int calc_it)
     {
         x->file_is_open = 0;
         x->mp3_out_index = 0;
-        fclose(x->fh);
+        sys_fclose(x->fh);
     }
       }
       else
       {
     x->file_is_open = 0;
-    fclose(x->fh);
+    sys_fclose(x->fh);
       }
   }
   x->play_state = 2;
diff --git a/externals/iemlib/iemlib1/src/soundfile_info.c b/externals/iemlib/iemlib1/src/soundfile_info.c
index f018370a69b53879df9fd6347b6509ed754b1e62..aa49cf5a4c1d40e1ffb5c3128bbb9bd35fd6f809 100644
--- a/externals/iemlib/iemlib1/src/soundfile_info.c
+++ b/externals/iemlib/iemlib1/src/soundfile_info.c
@@ -99,7 +99,7 @@ static void soundfile_info_overwrite_sr(t_soundfile_info *x, t_symbol *filename,
     strcat(completefilename, filename->s_name);
   }
   
-  fh = fopen(completefilename,"r+b");
+  fh = sys_fopen(completefilename,"r+b");
   if(!fh)
   {
     post("soundfile_info_read: cannot open %s !!\n", completefilename);
@@ -187,7 +187,7 @@ static void soundfile_info_overwrite_sr(t_soundfile_info *x, t_symbol *filename,
       
       fseek(fh,0,SEEK_SET);
       read_chars = (int)fwrite (x->x_begmem, sizeof(char), n4, fh);
-      fclose(fh);
+      sys_fclose(fh);
       post("written");
       
       sr = (int)ul_sr;
@@ -268,7 +268,7 @@ static void soundfile_info_read(t_soundfile_info *x, t_symbol *filename)
     strcat(completefilename, filename->s_name);
   }
   
-  fh = fopen(completefilename,"rb");
+  fh = sys_fopen(completefilename,"rb");
   if(!fh)
   {
     post("soundfile_info_read: cannot open %s !!\n", completefilename);
@@ -282,7 +282,7 @@ static void soundfile_info_read(t_soundfile_info *x, t_symbol *filename)
     filesize = ftell(fh);
     fseek(fh,0,SEEK_SET);
     read_chars = (int)fread(x->x_begmem, sizeof(char), n4, fh) / 2;
-    fclose(fh);
+    sys_fclose(fh);
     //    post("read chars = %d", read_chars);
     cvec = (char *)x->x_begmem;
     if(read_chars > 4)
diff --git a/externals/iemlib/iemlib2/src/iem_pbank_csv.c b/externals/iemlib/iemlib2/src/iem_pbank_csv.c
index cb919a9325c53add093008aa0ef9d60ecd096303..d24b055cdf3cfb80b295a03baed7c0fe451265e3 100644
--- a/externals/iemlib/iemlib2/src/iem_pbank_csv.c
+++ b/externals/iemlib/iemlib2/src/iem_pbank_csv.c
@@ -88,7 +88,7 @@ static void iem_pbank_csv_write(t_iem_pbank_csv *x, t_symbol *filename, t_symbol
     strcat(completefilename, filename->s_name);
   }
   
-  fh = fopen(completefilename,"wb");
+  fh = sys_fopen(completefilename,"wb");
   if(!fh)
   {
     post("iem_pbank_csv_write: cannot create %s !!\n", completefilename);
@@ -172,7 +172,7 @@ static void iem_pbank_csv_write(t_iem_pbank_csv *x, t_symbol *filename, t_symbol
         fprintf(fh, "%s%s", ap->a_w.w_symbol->s_name, eol+eol_offset);
       ap++;
     }
-    fclose(fh);
+    sys_fclose(fh);
     post("iem_pbank_csv: wrote %d parameters x %d lines to file:\n%s\nwith following format:\n%s\n", nrp, nrl, completefilename, formattext);
   }
 }
@@ -407,7 +407,7 @@ static void iem_pbank_csv_read(t_iem_pbank_csv *x, t_symbol *filename, t_symbol
        strcat(completefilename, filename->s_name);
      }
      
-     fh = fopen(completefilename,"rb");
+     fh = sys_fopen(completefilename,"rb");
      if(!fh)
      {
        post("iem_pbank_csv_read: cannot open %s !!\n", completefilename);
@@ -481,7 +481,7 @@ static void iem_pbank_csv_read(t_iem_pbank_csv *x, t_symbol *filename, t_symbol
        txbuf2 = (char *)getbytes((2 * txalloc + 256) * sizeof(char));
        if(fread(txbuf1, sizeof(char), txalloc, fh) < sizeof(char)*txalloc)
          post("pbank.csv:435: warning read error (not specified)");
-       fclose(fh);
+       sys_fclose(fh);
        
 	// 1.)  allow only readable ASCII (0x09, 0x0a, 0x0d, 0x20...0x7e = 
   //      = TAB, LF, CR, ' ' ... '~' = 
diff --git a/externals/lyonpotpourri/sigseq~.c b/externals/lyonpotpourri/sigseq~.c
index 7282b65fb37b5c7819b9d7c19386751f55ae39b8..8cffb3f26f153b5ab815978ffab743dc280d70b6 100755
--- a/externals/lyonpotpourri/sigseq~.c
+++ b/externals/lyonpotpourri/sigseq~.c
@@ -141,7 +141,7 @@ void sigseq_readfile(t_sigseq *x, t_symbol *filename)
     FILE *fp;
     float data;
     post("requested path: %s", filename->s_name);
-    fp = fopen(filename->s_name, "r");
+    fp = sys_fopen(filename->s_name, "r");
     if( fp == NULL ){
         post("could not open file!");
         return;
@@ -149,7 +149,7 @@ void sigseq_readfile(t_sigseq *x, t_symbol *filename)
     while( fscanf(fp, "%f", &data) != EOF ){
         post("%f",data);
     }
-    fclose(fp);
+    sys_fclose(fp);
 }
 
 void sigseq_mute(t_sigseq *x, t_symbol *msg, short argc, t_atom *argv)
diff --git a/externals/moonlib/image.c b/externals/moonlib/image.c
index f8a1fe2e096c85945f19d3b3319726fa68938901..0146cdf9b9352914a3f3ef1c6fe49380c6bd3993 100644
--- a/externals/moonlib/image.c
+++ b/externals/moonlib/image.c
@@ -43,7 +43,7 @@ static const char *image_get_filename(t_image *x, char *file)
            retrieve the full path... */
         fullpath = dirresult;
         fullpath[strlen(fullpath)] = '/';
-        close(fd);
+        sys_close(fd);
         return fullpath;
     }
     else return 0;
diff --git a/externals/moonlib/readsfv~.c b/externals/moonlib/readsfv~.c
index 1c2cb5291c75d3d7a1f2da90a6b52078383c27f7..ec2c2315662535c1083a514a16c19921365f9b80 100644
--- a/externals/moonlib/readsfv~.c
+++ b/externals/moonlib/readsfv~.c
@@ -523,12 +523,12 @@ static int create_soundfile2(t_canvas *canvas, const char *filename,
 
     canvas_makefilename(canvas, filenamebuf, buf2, MAXPDSTRING);
     sys_bashfilename(buf2, buf2);
-    if ((fd = open(buf2, BINCREATE, 0666)) < 0)
+    if ((fd = sys_open(buf2, BINCREATE, 0666)) < 0)
         return (-1);
 
     if (write(fd, headerbuf, headersize) < headersize)
     {
-        close (fd);
+        sys_close (fd);
         return (-1);
     }
     return (fd);
@@ -914,7 +914,7 @@ static void soundfiler2_read(t_soundfiler2 *x, t_symbol *s,
     /* do all graphics updates */
     for (i = 0; i < argc; i++)
         garray_redraw(garrays[i]);
-    fclose(fp);
+    sys_fclose(fp);
     fd = -1;
     goto done;
 usage:
@@ -923,7 +923,7 @@ usage:
     post("-raw <headerbytes> <channels> <bytespersamp> <endian (b, l, or n)>.");
 done:
     if (fd >= 0)
-        close (fd);
+        sys_close (fd);
     outlet_float(x->x_obj.ob_outlet, (float)itemsread);
 }
 
@@ -1029,7 +1029,7 @@ static long soundfiler2_dowrite(void *obj, t_canvas *canvas,
     {
         soundfile_finishwrite(obj, filesym->s_name, fd,
                               filetype, nframes, itemswritten, nchannels * bytespersamp, swap);
-        close (fd);
+        sys_close (fd);
     }
     return ((float)itemswritten);
 usage:
@@ -1039,7 +1039,7 @@ usage:
     post("(defaults to a 16-bit wave file).");
 fail:
     if (fd >= 0)
-        close (fd);
+        sys_close (fd);
     return (0);
 }
 
@@ -1230,7 +1230,7 @@ static void *readsf_child_main(void *zz)
             {
                 fd = x->x_fd;
                 pthread_mutex_unlock(&x->x_mutex);
-                close (fd);
+                sys_close (fd);
                 pthread_mutex_lock(&x->x_mutex);
                 x->x_fd = -1;
                 if (x->x_requestcode != REQUEST_BUSY)
@@ -1383,7 +1383,7 @@ lost:
             {
                 fd = x->x_fd;
                 pthread_mutex_unlock(&x->x_mutex);
-                close (fd);
+                sys_close (fd);
                 pthread_mutex_lock(&x->x_mutex);
                 x->x_fd = -1;
             }
@@ -1396,7 +1396,7 @@ lost:
             {
                 fd = x->x_fd;
                 pthread_mutex_unlock(&x->x_mutex);
-                close (fd);
+                sys_close (fd);
                 pthread_mutex_lock(&x->x_mutex);
                 x->x_fd = -1;
             }
@@ -1410,7 +1410,7 @@ lost:
             {
                 fd = x->x_fd;
                 pthread_mutex_unlock(&x->x_mutex);
-                close (fd);
+                sys_close (fd);
                 pthread_mutex_lock(&x->x_mutex);
                 x->x_fd = -1;
             }
diff --git a/externals/moonlib/sfread2~.c b/externals/moonlib/sfread2~.c
index e5e2a6fb9df352e99c4c28856ccfb9b43af9226c..8e7329bca2b696f3547ba42426e58129d76f64ef 100644
--- a/externals/moonlib/sfread2~.c
+++ b/externals/moonlib/sfread2~.c
@@ -317,7 +317,7 @@ static void sfread_open(t_sfread *x,t_symbol *filename)
     /* close the old file */
 
     if (x->x_mapaddr) munmap(x->x_mapaddr,x->x_size);
-    if (x->x_fd >= 0) close(x->x_fd);
+    if (x->x_fd >= 0) sys_close(x->x_fd);
 
     /*if ((x->x_fd = open(fname,O_RDONLY)) < 0)*/
     //post("fname: %s",fname);
diff --git a/externals/tb/sndfiler/src/file_input.c b/externals/tb/sndfiler/src/file_input.c
index 79ad27e37d769ce3e7e5b3b95d5b907408ae192a..210a0806072b56cce73834bd01994e3d8ec330f5 100644
--- a/externals/tb/sndfiler/src/file_input.c
+++ b/externals/tb/sndfiler/src/file_input.c
@@ -27,12 +27,12 @@ int check_fileformat(t_symbol* file)
     OggVorbis_File vorbisfile;
 
     // partially opens a vorbis file to test for Vorbis-ness
-    if( !(fp = fopen(file->s_name, "r")) )
+    if( !(fp = sys_fopen(file->s_name, "r")) )
         return -1;
 
     if( ov_test(fp, &vorbisfile, NULL, 0) < 0 )
     {
-        fclose(fp);
+        sys_fclose(fp);
         return USE_LIBSNDFILE;
     }
 
@@ -145,12 +145,12 @@ int read_libvorbisfile(t_float** helper_arrays, int channel_count, int seek,
     OggVorbis_File vorbisfile;
     vorbis_info *info;
 
-    if( !(fp = fopen(file->s_name, "r")) )
+    if( !(fp = sys_fopen(file->s_name, "r")) )
         return -1;
 
     if( ov_open(fp, &vorbisfile, NULL, 0) < 0 )
     {
-        fclose(fp);
+        sys_fclose(fp);
         return -1;
     }