Index: /trunk/zoo-project/zoo-kernel/caching.c
===================================================================
--- /trunk/zoo-project/zoo-kernel/caching.c	(revision 954)
+++ /trunk/zoo-project/zoo-kernel/caching.c	(revision 955)
@@ -25,8 +25,8 @@
 #include <openssl/md5.h>
 #include <openssl/evp.h>
-#include "caching.h"
 #include "service.h"
 #include "service_internal.h"
 #include "response_print.h"
+#include "caching.h"
 #ifdef MS_FORCE_LOCAL_FILE_USE
 #include "ogr_api.h"
Index: /trunk/zoo-project/zoo-kernel/response_print.c
===================================================================
--- /trunk/zoo-project/zoo-kernel/response_print.c	(revision 954)
+++ /trunk/zoo-project/zoo-kernel/response_print.c	(revision 955)
@@ -23,4 +23,5 @@
  */
 
+#include "response_print.h"
 #ifdef USE_MS
 #include "service_internal_ms.h"
@@ -34,5 +35,4 @@
 #include "service_internal.h"
 #include "server_internal.h"
-#include "response_print.h"
 
 #ifndef WIN32
Index: /trunk/zoo-project/zoo-kernel/service.c
===================================================================
--- /trunk/zoo-project/zoo-kernel/service.c	(revision 954)
+++ /trunk/zoo-project/zoo-kernel/service.c	(revision 955)
@@ -130,7 +130,7 @@
     fflush(file);
     tmp=tmp->next;
+    cnt++;
     if(limit>=0 && cnt==limit)
       tmp=NULL;
-    cnt++;
   }
   fflush(file);
Index: /trunk/zoo-project/zoo-kernel/service_callback.c
===================================================================
--- /trunk/zoo-project/zoo-kernel/service_callback.c	(revision 954)
+++ /trunk/zoo-project/zoo-kernel/service_callback.c	(revision 955)
@@ -27,5 +27,4 @@
  */
 
-#include "service_callback.h"
 #include "service_json.h"
 #include "service_internal_ms.h"
@@ -41,4 +40,6 @@
 #include <libxslt/transform.h>
 #include <libxslt/xsltutils.h>
+
+#include "service_callback.h"
 
 #ifdef __cplusplus
Index: /trunk/zoo-project/zoo-kernel/service_callback.h
===================================================================
--- /trunk/zoo-project/zoo-kernel/service_callback.h	(revision 954)
+++ /trunk/zoo-project/zoo-kernel/service_callback.h	(revision 955)
@@ -32,8 +32,8 @@
 #pragma once
 
+#include <ulinet.h>
 #include <stdio.h>
 #include <ctype.h>
 #include <service.h>
-#include <ulinet.h>
 
 #ifdef __cplusplus
Index: /trunk/zoo-project/zoo-kernel/service_internal_hpc.c
===================================================================
--- /trunk/zoo-project/zoo-kernel/service_internal_hpc.c	(revision 954)
+++ /trunk/zoo-project/zoo-kernel/service_internal_hpc.c	(revision 955)
@@ -1056,7 +1056,4 @@
 		maps* tmp=getMaps(*real_outputs,input->name);
 		char serviceName[9];
-		freeMap(&tmp->content);
-		free(tmp->content);
-		tmp->content=NULL;
 		maps* output=getMaps(*real_outputs,input->name);
 		setMapInMaps(output->child,"download_link","generated_file",targetPath);
@@ -1067,21 +1064,26 @@
 		setMapInMaps(output->child,"download_link","asReference","true");
 		setMapInMaps(output->child,"download_link","inRequest","true");
-		setMapInMaps(output->child,"wms_link","generated_file",targetPath);
-		setMapInMaps(output->child,"wms_link","storage",targetPath);
-		setMapInMaps(output->child,"wms_link","useMapserver","true");
-		setMapInMaps(output->child,"wms_link","msOgc","WMS");
-		setMapInMaps(output->child,"wms_link","requestedMimeType","image/png");
-		setMapInMaps(output->child,"wms_link","asReference","true");
-		if(getMaps(output->child,"wcs_link")!=NULL){
-		  sprintf(serviceName,"wcs_link");
-		  setMapInMaps(output->child,"wcs_link","msOgc","WCS");
-		}else{
-		  sprintf(serviceName,"wfs_link");
-		  setMapInMaps(output->child,"wfs_link","msOgc","WFS");
-                }
-		setMapInMaps(output->child,serviceName,"storage",targetPath);
-		setMapInMaps(output->child,serviceName,"generated_file",targetPath);
-		setMapInMaps(output->child,serviceName,"useMapserver","true");
-		setMapInMaps(output->child,serviceName,"asReference","true");
+		if(getMaps(output->child,"wms_link")!=NULL){
+		  setMapInMaps(output->child,"wms_link","generated_file",targetPath);
+		  setMapInMaps(output->child,"wms_link","storage",targetPath);
+		  setMapInMaps(output->child,"wms_link","useMapserver","true");
+		  setMapInMaps(output->child,"wms_link","msOgc","WMS");
+		  setMapInMaps(output->child,"wms_link","requestedMimeType","image/png");
+		  setMapInMaps(output->child,"wms_link","asReference","true");
+		  if(getMaps(output->child,"wcs_link")!=NULL){
+		    sprintf(serviceName,"wcs_link");
+		    setMapInMaps(output->child,"wcs_link","msOgc","WCS");
+		  }else{
+		    sprintf(serviceName,"wfs_link");
+		    setMapInMaps(output->child,"wfs_link","msOgc","WFS");
+		  }
+		  setMapInMaps(output->child,serviceName,"storage",targetPath);
+		  setMapInMaps(output->child,serviceName,"generated_file",targetPath);
+		  setMapInMaps(output->child,serviceName,"useMapserver","true");
+		  setMapInMaps(output->child,serviceName,"asReference","true");
+		}
+		freeMap(&tmp->content);
+		free(tmp->content);
+		tmp->content=NULL;
 	      }else{
 		map* hpcStdErr=getMapFromMaps(*main_conf,"henv","StdErr");
Index: /trunk/zoo-project/zoo-kernel/service_internal_ms.c
===================================================================
--- /trunk/zoo-project/zoo-kernel/service_internal_ms.c	(revision 954)
+++ /trunk/zoo-project/zoo-kernel/service_internal_ms.c	(revision 955)
@@ -1528,5 +1528,5 @@
   msFreeMap(myMap);
   //msFree(myMap);
-  msGDALCleanup();
+  //msGDALCleanup();
 }
 
Index: /trunk/zoo-project/zoo-kernel/sqlapi.c
===================================================================
--- /trunk/zoo-project/zoo-kernel/sqlapi.c	(revision 954)
+++ /trunk/zoo-project/zoo-kernel/sqlapi.c	(revision 955)
@@ -31,7 +31,6 @@
 #endif
 
+#include <fcgi_stdio.h>
 #include "sqlapi.h"
-#include <fcgi_stdio.h>
-#include <stdlib.h>
 
 /**
Index: /trunk/zoo-project/zoo-kernel/ulinet.c
===================================================================
--- /trunk/zoo-project/zoo-kernel/ulinet.c	(revision 954)
+++ /trunk/zoo-project/zoo-kernel/ulinet.c	(revision 955)
@@ -269,4 +269,5 @@
  */
 char* getProvenance(maps* conf,const char* url){
+  int i=0;
   map* sharedCache=getMapFromMaps(conf,"security","shared");
   char *res="OTHER";
@@ -285,5 +286,5 @@
     }
   }
-  for(int i=0;i<2;i++){
+  for(i=0;i<2;i++){
     sharedCache=getMapFromMaps(conf,"main",paths[i]);
     if(sharedCache!=NULL){
Index: /trunk/zoo-project/zoo-kernel/zoo_service_loader.c
===================================================================
--- /trunk/zoo-project/zoo-kernel/zoo_service_loader.c	(revision 954)
+++ /trunk/zoo-project/zoo-kernel/zoo_service_loader.c	(revision 955)
@@ -69,8 +69,8 @@
 #include "response_print.h"
 #include "request_parser.h"
-#include "sqlapi.h"
 #ifdef USE_JSON
 #include "caching.h"
 #endif
+#include "sqlapi.h"
 
 #ifdef META_DB
@@ -1872,5 +1872,5 @@
   
   setMapInMaps(m,"lenv","executionType","xml");
-  if((strlen(cgiQueryString)>0 && cgiQueryString[0]=='/') || strstr(cgiAccept,"json")!=NULL){
+  if((strlen(cgiQueryString)>0 && cgiQueryString[0]=='/') && strstr(cgiAccept,"json")!=NULL){
   //
   // OGC API - Processing starts here
