Index: /trunk/zoo-project/zoo-kernel/service.h
===================================================================
--- /trunk/zoo-project/zoo-kernel/service.h	(revision 553)
+++ /trunk/zoo-project/zoo-kernel/service.h	(revision 554)
@@ -46,10 +46,16 @@
   long tv_usec; /* and microseconds */
 };
-void zGettimeofday(struct mstimeval* tp, void* tzp)
+static int zGettimeofday(struct ztimeval* tp, void* tzp)
 {
+  if (tp == 0) {
+    return -1;
+  }
+  
   struct _timeb theTime;
   _ftime(&theTime);
   tp->tv_sec = theTime.time;
   tp->tv_usec = theTime.millitm * 1000;
+  
+  return 0; // The gettimeofday() function shall return 0 on success
 }
 #else
Index: /trunk/zoo-project/zoo-kernel/service_internal.c
===================================================================
--- /trunk/zoo-project/zoo-kernel/service_internal.c	(revision 553)
+++ /trunk/zoo-project/zoo-kernel/service_internal.c	(revision 554)
@@ -124,27 +124,31 @@
 #define SHMEMSIZE 4096
 
-char* getKeyValue(maps* conf){
-  if(conf==NULL)
-     return "700666";
+size_t getKeyValue(maps* conf, char* key, size_t length){
+  
+  if(conf==NULL) {
+	 strncpy(key, "700666", length);
+	 return strlen(key);
+  }
+  
   map *tmpMap=getMapFromMaps(conf,"lenv","lid");
   if(tmpMap==NULL)
-    tmpMap=getMapFromMaps(conf,"lenv","usid");
-  char* key="-1";
+	tmpMap=getMapFromMaps(conf,"lenv","usid");
+
   if(tmpMap!=NULL){
-    key=(char*)malloc((strlen(tmpMap->value)+9)*sizeof(char));
-    sprintf(key,"zoo_sem_%s",tmpMap->value);
-  }
-  return key;
-}
-
-
+	snprintf(key, length, "zoo_sem_%s", tmpMap->value);      
+  }
+  else {
+	strncpy(key, "-1", length);  
+  }
+  return strlen(key);
+} 
 semid getShmLockId(maps* conf, int nsems){
     semid sem_id;
-    char* key=getKeyValue(conf);
+	char key[MAX_PATH];
+	getKeyValue(conf, key, MAX_PATH);
     
     sem_id = CreateSemaphore( NULL, nsems, nsems+1, key);
     if(sem_id==NULL){
-      if(strncmp(key,"-1",2)!=0)
-	free(key);
+
 #ifdef DEBUG
       fprintf(stderr,"Semaphore failed to create ! %s\n",GetLastError());
@@ -155,6 +159,5 @@
     fprintf(stderr,"%s Accessed !\n",key);
 #endif
-    if(strncmp(key,"-1",2)!=0)
-      free(key);
+
     return sem_id;
 }
@@ -3335,5 +3338,5 @@
 	      mimeType=strdup("none");
 	    else
-	      mimeType=strdup((char*)hInternet->ihandle[index].mimeType);
+		  mimeType=strdup(hInternet->ihandle[index].mimeType);	      
 	    
 	    map* tmpMap=getMapOrFill(&content->content,vname,"");
Index: /trunk/zoo-project/zoo-kernel/ulinet.h
===================================================================
--- /trunk/zoo-project/zoo-kernel/ulinet.h	(revision 553)
+++ /trunk/zoo-project/zoo-kernel/ulinet.h	(revision 554)
@@ -80,5 +80,5 @@
   size_t size;
   unsigned char *pabyData;
-  unsigned char *mimeType;
+  char *mimeType;
   int hasCacheFile;
   int nDataLen;
Index: /trunk/zoo-project/zoo-kernel/zoo_loader.c
===================================================================
--- /trunk/zoo-project/zoo-kernel/zoo_loader.c	(revision 553)
+++ /trunk/zoo-project/zoo-kernel/zoo_loader.c	(revision 554)
@@ -37,4 +37,6 @@
 #include <unistd.h>
 #include "service_internal.h"
+
+
 #ifdef WIN32
 #include "windows.h"
Index: /trunk/zoo-project/zoo-kernel/zoo_service_loader.c
===================================================================
--- /trunk/zoo-project/zoo-kernel/zoo_service_loader.c	(revision 553)
+++ /trunk/zoo-project/zoo-kernel/zoo_service_loader.c	(revision 554)
@@ -781,4 +781,10 @@
   fprintf (stderr, "REQUEST IS : %s \n", tmp);
 #endif
+
+  map* usid = getMapFromMaps (m, "lenv", "usid");
+  if (usid != NULL && usid->value != NULL) {
+    SetEnvironmentVariable("USID", TEXT (usid->value));
+  }
+
   SetEnvironmentVariable ("CGISID", TEXT (sid->value));
   SetEnvironmentVariable ("QUERY_STRING", TEXT (tmpq));
@@ -824,5 +830,7 @@
 
 #ifndef USE_GDB
+#ifndef WIN32
   signal (SIGCHLD, SIG_IGN);
+#endif  
   signal (SIGSEGV, sig_handler);
   signal (SIGTERM, sig_handler);
@@ -3203,5 +3211,5 @@
   _tmpMaps->name = zStrdup ("lenv");
   char tmpBuff[100];
-  int lid = getShmLockId (NULL, 1);
+  semid lid = getShmLockId (NULL, 1);
   lockShm (lid);
   struct ztimeval tp;
@@ -3307,4 +3315,10 @@
   if (getenv ("CGISID") != NULL)
     addToMap (request_inputs, "cgiSid", getenv ("CGISID"));
+
+  char* usidp;
+  if ( (usidp = getenv("USID")) != NULL ) {
+    setMapInMaps (m, "lenv", "usid", usidp);
+  }
+
   map *test1 = getMap (request_inputs, "cgiSid");
   if (test1 != NULL)
