Index: OMCompiler/Compiler/Template/CodegenC.tpl
===================================================================
--- OMCompiler/Compiler/Template/CodegenC.tpl	(revision None)
+++ OMCompiler/Compiler/Template/CodegenC.tpl	(revision None)
@@ -1428,51 +1428,54 @@
     <% match isModelExchangeFMU
     case "1.0" then
-    <<
-    data->modelData->initXMLData = NULL;
-    data->modelData->modelDataXml.infoXMLData =
-    #if defined(OMC_MINIMAL_METADATA)
-      NULL;
-    #else
-    #include "<%fileNamePrefix%>_info.c"
-    #endif
-    ;
-    >>
+      <<
+      data->modelData->initXMLData = NULL;
+      data->modelData->modelDataXml.infoXMLData =
+      #if defined(OMC_MINIMAL_METADATA)
+        NULL;
+      #else
+        #include "<%fileNamePrefix%>_info.c"
+        ;
+      #endif
+      data->modelData->modelDataXml.fileName = NULL;
+      >>
     case "" then
-    <<
-    #if defined(OPENMODELICA_XML_FROM_FILE_AT_RUNTIME)
-    data->modelData->initXMLData = NULL;
-    data->modelData->modelDataXml.infoXMLData = NULL;
-    #else
-    #if defined(_MSC_VER) /* handle joke compilers */
-    {
-    /* for MSVC we encode a string like char x[] = {'a', 'b', 'c', '\0'} */
-    /* because the string constant limit is 65535 bytes */
-    static const char contents_init[] =
+      <<
+      #if defined(OPENMODELICA_XML_FROM_FILE_AT_RUNTIME)
+      data->modelData->initXMLData = NULL;
+      data->modelData->modelDataXml.infoXMLData = NULL;
+      #else
+      #if defined(_MSC_VER) /* handle joke compilers */
+      {
+      /* for MSVC we encode a string like char x[] = {'a', 'b', 'c', '\0'} */
+      /* because the string constant limit is 65535 bytes */
+      static const char contents_init[] =
+        #include "<%fileNamePrefix%>_init.c"
+        ;
+      static const char contents_info[] =
+        #include "<%fileNamePrefix%>_info.c"
+        ;
+        data->modelData->initXMLData = contents_init;
+        data->modelData->modelDataXml.infoXMLData = contents_info;
+      }
+      #else /* handle real compilers */
+      data->modelData->initXMLData =
       #include "<%fileNamePrefix%>_init.c"
-      ;
-    static const char contents_info[] =
+        ;
+      data->modelData->modelDataXml.infoXMLData =
       #include "<%fileNamePrefix%>_info.c"
-      ;
-      data->modelData->initXMLData = contents_init;
-      data->modelData->modelDataXml.infoXMLData = contents_info;
-    }
-    #else /* handle real compilers */
-    data->modelData->initXMLData =
-    #include "<%fileNamePrefix%>_init.c"
-      ;
-    data->modelData->modelDataXml.infoXMLData =
-    #include "<%fileNamePrefix%>_info.c"
-      ;
-    #endif /* defined(_MSC_VER) */
-    #endif /* defined(OPENMODELICA_XML_FROM_FILE_AT_RUNTIME) */
-    >>
+        ;
+      #endif /* defined(_MSC_VER) */
+      #endif /* defined(OPENMODELICA_XML_FROM_FILE_AT_RUNTIME) */
+      data->modelData->modelDataXml.fileName = "<%fileNamePrefix%>_info.json";
+      data->modelData->resourcesDir = NULL;
+      >>
     else
-    <<
-    data->modelData->initXMLData = NULL;
-    data->modelData->modelDataXml.infoXMLData = NULL;
-    >>
+      <<
+      data->modelData->initXMLData = NULL;
+      data->modelData->modelDataXml.infoXMLData = NULL;
+      else 'GC_asprintf(&data->modelData->modelDataXml.fileName, "%s/<%fileNamePrefix%>_info.json", data->modelData->resourcesDir);'
+      >>
     %>
     data->modelData->runTestsuite = <%if Testsuite.isRunning() then "1" else "0"%>;
-
     data->modelData->nStates = <%varInfo.numStateVars%>;
     data->modelData->nVariablesReal = <%nVariablesReal(varInfo)%>;
@@ -1487,10 +1490,8 @@
     data->modelData->nInputVars = <%varInfo.numInVars%>;
     data->modelData->nOutputVars = <%varInfo.numOutVars%>;
-
     data->modelData->nAliasReal = <%varInfo.numAlgAliasVars%>;
     data->modelData->nAliasInteger = <%varInfo.numIntAliasVars%>;
     data->modelData->nAliasBoolean = <%varInfo.numBoolAliasVars%>;
     data->modelData->nAliasString = <%varInfo.numStringAliasVars%>;
-
     data->modelData->nZeroCrossings = <%varInfo.numZeroCrossings%>;
     data->modelData->nSamples = <%varInfo.numTimeEvents%>;
@@ -1498,10 +1499,4 @@
     data->modelData->nMathEvents = <%varInfo.numMathEventFunctions%>;
     data->modelData->nExtObjs = <%varInfo.numExternalObjects%>;
-
-    <% match isModelExchangeFMU
-    case "1.0" then "data->modelData->modelDataXml.fileName = NULL;"
-    case "" then 'data->modelData->modelDataXml.fileName = "<%fileNamePrefix%>_info.json";'
-    else 'GC_asprintf(&data->modelData->modelDataXml.fileName, "%s/<%fileNamePrefix%>_info.json", data->modelData->resourcesDir);'
-    %>
     data->modelData->modelDataXml.modelInfoXmlLength = 0;
     data->modelData->modelDataXml.nFunctions = <%listLength(functions)%>;
@@ -1515,12 +1510,8 @@
     data->modelData->nOptimizeConstraints = <%varInfo.numOptimizeConstraints%>;
     data->modelData->nOptimizeFinalConstraints = <%varInfo.numOptimizeFinalConstraints%>;
-
     data->modelData->nDelayExpressions = <%match delayed case
      DELAYED_EXPRESSIONS(__) then maxDelayedIndex%>;
-
     data->modelData->nBaseClocks = <%nClocks%>;
-
     data->modelData->nSpatialDistributions = <%nSpatialDistributions%>;
-
     data->modelData->nSensitivityVars = <%listLength(vars.sensitivityVars)%>;
     data->modelData->nSensitivityParamVars = <%varInfo.numSensitivityParameters%>;
@@ -1529,6 +1520,5 @@
     data->modelData->nSetbVars = <%varInfo.numSetbVars%>;
     data->modelData->nRelatedBoundaryConditions = <%varInfo.numRelatedBoundaryConditions%>;
-    data->modelData->linearizationDumpLanguage =
-    <%
+    data->modelData->linearizationDumpLanguage = <%
     if stringEq(Flags.getConfigString(LINEARIZATION_DUMP_LANGUAGE),"modelica") then 'OMC_LINEARIZE_DUMP_LANGUAGE_MODELICA'
     else if stringEq(Flags.getConfigString(LINEARIZATION_DUMP_LANGUAGE),"matlab") then 'OMC_LINEARIZE_DUMP_LANGUAGE_MATLAB'
Index: OMCompiler/SimulationRuntime/c/util/jacobian_util.c
===================================================================
--- OMCompiler/SimulationRuntime/c/util/jacobian_util.c	(revision None)
+++ OMCompiler/SimulationRuntime/c/util/jacobian_util.c	(revision None)
@@ -136,5 +136,5 @@
 /**
  * @brief Opens sparsity pattern file
- * 
+ *
  * @param data        Runtime data struct.
  * @param threadData  Thread data for error handling.
@@ -143,25 +143,21 @@
  */
 FILE * openSparsePatternFile(DATA* data, threadData_t *threadData, const char* filename) {
-  char* fullPath = NULL;
   FILE* pFile;
 
-  if(data->modelData->resourcesDir) {
-    size_t len1 = strlen(data->modelData->resourcesDir);
-    size_t len2 = strlen(filename);
-    size_t length = len1 + 1 + len2 + 1;
-    fullPath = malloc(length*sizeof(char));
+  if (data->modelData->resourcesDir) {
+    size_t length = strlen(data->modelData->resourcesDir) + 1 + strlen(filename) + 1;
+    char* fullPath = malloc(length*sizeof(char));
     sprintf(fullPath, "%s/%s", data->modelData->resourcesDir, filename);
     pFile = omc_fopen(fullPath, "rb");
+    if (pFile == NULL) {
+      throwStreamPrint(threadData, "Could not open sparsity pattern file %s.", fullPath);
+    }
+    free(fullPath);
   } else {
     pFile = omc_fopen(filename, "rb");
-  }
-
-  if (pFile == NULL) {
-    free(fullPath);
-    throwStreamPrint(threadData, "Could not open sparsity pattern file %s.", fullPath);
-  }
-
-  free(fullPath);
-
+    if (pFile == NULL) {
+      throwStreamPrint(threadData, "Could not open sparsity pattern file %s.", filename);
+    }
+  }
   return pFile;
 }
Index: OMCompiler/SimulationRuntime/c/util/omc_file.h
===================================================================
--- OMCompiler/SimulationRuntime/c/util/omc_file.h	(revision None)
+++ OMCompiler/SimulationRuntime/c/util/omc_file.h	(revision None)
@@ -68,11 +68,7 @@
 #endif // defined(__MINGW32__) || defined(_MSC_VER)
 
-
 FILE* omc_fopen(const char *filename, const char *mode);
-
 int omc_fclose(FILE * stream);
-
 size_t omc_fread(void *buffer, size_t size, size_t count, FILE *stream, int allow_early_eof);
-
 size_t omc_fwrite(void * buffer, size_t size, size_t count, FILE * stream);
 
