diff --git a/runtime/src/kaapi_ompt.c b/runtime/src/kaapi_ompt.c
index 2fea70373418be3299f2915e9260ce1f75445cfe..1311e19418de1b95e677435b2b6b022a8d407376 100644
--- a/runtime/src/kaapi_ompt.c
+++ b/runtime/src/kaapi_ompt.c
@@ -434,7 +434,7 @@ on_ompt_event_loop_begin(
   void *workshare_function,
   int schedule, int64_t lb, int64_t ub, int64_t stride, uint64_t chunk, uint64_t count)
 {
-#if 1//LOG
+#if LOG
   printf("%" PRIu64 ": ompt_event_loop_begin: parallel_id=%" PRIu64 ", parent_task_id=%" PRIu64
     ", workshare_id=%" PRIu64 ", loc: %s, workshare_function=%p, schedule: %i"
     " [%" PRIi64 ":%" PRIi64 ":%" PRIi64 "], chunk:%" PRIu64 ", count:%" PRIu64 "\n",
@@ -460,7 +460,7 @@ on_ompt_event_loop_dispatch(
   int64_t lb, int64_t ub, int64_t stride
 )
 {
-#if 1//LOG
+#if LOG
   printf("%" PRIu64 ": ompt_event_loop_dispatch: parallel_id=%" PRIu64 ", parent_task_id=%" PRIu64
     ", workshare_id=%" PRIu64 ", [%" PRIi64 ":%" PRIi64 ":%" PRIi64 "]\n",
     thread_id-1, parallel_id, task_id, workshare_id, lb, stride, ub);
@@ -480,7 +480,7 @@ on_ompt_event_loop_end(
   ompt_workshare_id_t workshare_id
   )
 {
-#if 1//LOG
+#if LOG
   printf("%" PRIu64 ": ompt_event_loop_end: parallel_id=%" PRIu64 ", task_id=%" PRIu64
     ", workshare_id=%" PRIu64 "\n", thread_id-1, parallel_id, task_id, workshare_id);
 #endif
diff --git a/runtime/src/kaapi_trace.h b/runtime/src/kaapi_trace.h
index 886c821cd219894bff94dd42ed831ed7d9719fcb..eb558796946b499be7c453b6edb62d9743fc092c 100644
--- a/runtime/src/kaapi_trace.h
+++ b/runtime/src/kaapi_trace.h
@@ -335,6 +335,7 @@ typedef uint64_t kaapi_event_mask_type_t;
      | KAAPI_EVT_MASK(KAAPI_EVT_LOOP_BEGIN) \
      | KAAPI_EVT_MASK(KAAPI_EVT_LOOP_END) \
      | KAAPI_EVT_MASK(KAAPI_EVT_LOOP_NEXT) \
+     | KAAPI_EVT_MASK(KAAPI_EVT_LOOP_MDATA) \
     )
 
 #define KAAPI_EVT_MASK_SCHED \
diff --git a/runtime/src/kaapi_trace_rt.c b/runtime/src/kaapi_trace_rt.c
index 6fde47344fba181c8999e1a517335c1ce333d1c3..b3beef50833efa230623a0f88e9c73ac1076e6ae 100644
--- a/runtime/src/kaapi_trace_rt.c
+++ b/runtime/src/kaapi_trace_rt.c
@@ -106,7 +106,8 @@ const char* kaapi_event_name[]
 /*50 */  "ThreadStealOp",
 /*51 */  "ThreadState",
 /*52 */  "Energy",
-/*53 */  "Watt"
+/*53 */  "Watt",
+/*54 */  "LoopMData"
 };
 
 
diff --git a/runtime/src/katracereader.cpp b/runtime/src/katracereader.cpp
index 1f6695f1d0c23b8da054f501fabbe78bb9a68c2b..27b41616dd8174f9a71aaec61e095e104eb4aa91 100644
--- a/runtime/src/katracereader.cpp
+++ b/runtime/src/katracereader.cpp
@@ -1336,7 +1336,7 @@ struct kproc_t : public state_t {
 
 /* Keep track of the thread state event */
 struct loopinfo_t : public event_t {
-  enum { BEGIN, END, DISPATCH };
+  enum { BEGIN, DISPATCH, END };
   loopinfo_t(int k)
    : event_t(), type(k), wid(0), count(0), ub(0), lb(0), stride(0)
   {}
@@ -1975,8 +1975,10 @@ printf("pred[id:%i/%p] = {id:%i}/%p\n", succ->id, (void*)succ->addr, task->id, (
       li.start = event->date;
       li.kid   = kid;
       li.wid   = KAAPI_EVENT_DATA(event,0,u);
-      rpr->loopevts.push_back( li );
       loopstate_t& ls = rpr->loopstack[kid].back();
+
+      if (li.wid == (uint64_t)-1) li.wid = ls.wid;
+      rpr->loopevts.push_back( li );
       ls.stop  = event->date;
       ls.kid   = kid;
       ls.wid   = li.wid;
@@ -2582,7 +2584,7 @@ int csv_parallel_region_t::closefile(int cpucount)
   }
   /* header */
   fprintf(csv_parallel_region_t::fout_loops,
-    "Resource, Stamp, Wid, EvtType, UB, LB, Stride"
+    "Resource, Stamp, Wid, EvtType, UB, LB, Stride\n"
   );
   for (size_t i=0; i<loopevts.size(); ++i)
   {
@@ -2725,6 +2727,12 @@ static void fnc_csv( int count, const char** filenames )
     fprintf(stdout,"*** File 'complexity.csv' generated\n");
     csv_parallel_region_t::fout_complexity = 0;
   }
+  if (csv_parallel_region_t::fout_loops)
+  {
+    fclose(csv_parallel_region_t::fout_loops);
+    fprintf(stdout,"*** File 'loops.csv' generated\n");
+    csv_parallel_region_t::fout_loops = 0;
+  }
 
 
   rastello_fmtname.clear();