diff --git a/src/engine.c b/src/engine.c
index ca4987a1e9cdcaeaa39c164ddc2c256780dfa2f2..418b458d2fd201643b92846079f8ae23640b511d 100644
--- a/src/engine.c
+++ b/src/engine.c
@@ -97,6 +97,7 @@ const char *engine_policy_names[] = {"none",
 
 /** The rank of the engine as a global variable (for messages). */
 int engine_rank;
+extern int outputCount;
 
 /**
  * @brief Data collected from the cells at the end of a time-step
@@ -4385,6 +4386,65 @@ void engine_step(struct engine *e) {
       engine_drift_top_multipoles(e);
   }
 
+  // MATTHIEU ---------------
+
+  //  const int cell_count = e->s->nr_parts / (e->s->cdim[0] * e->s->cdim[1]);
+  
+  for(size_t i = 0; i < e->s->nr_parts; ++i) {
+
+    const struct part *p = &e->s->parts[i];
+
+    /* find cell */
+    int cid = 0;
+    for(; cid < e->s->nr_cells - 1; ++cid)
+      if(p >= e->s->cells_top[cid].parts && p < e->s->cells_top[cid+1].parts)
+	break;
+    const struct cell *c = &e->s->cells_top[cid];
+    
+    //if(c->count != cell_count) error("oO");
+    
+
+    const int c_active = cell_is_active_hydro(c, e);
+    const int p_active = part_is_active(p, e);
+
+    if(p_active && !c_active) error("Inactive cell with active particle");
+
+    if(p->h > c->h_max) error("Invalid h");
+    
+    if(c_active) {
+
+      int count_density = 0;
+      
+      /* Loop over the density task of the cell */
+      for(struct link *l = c->density; l != NULL; l = l->next) {
+
+	const struct task *t = l->t;
+	if(t->skip) error("Skipped density task");
+
+	++count_density;
+	
+      }
+      if(count_density != 9) error("Incorrect number of density tasks");
+      
+      int count_force = 0;
+      
+      /* Loop over the force task of the cell */
+      for(struct link *l = c->force; l != NULL; l = l->next) {
+
+	const struct task *t = l->t;
+	if(t->skip) error("Skipped force task");
+
+	++count_force;
+	
+      }
+
+      if(count_force != 9) error("Incorrect number of force tasks");
+    }
+  }
+
+
+  // MATTHIEU ---------------
+      
   /* Print the number of active tasks ? */
   if (e->verbose) engine_print_task_counts(e);
 
@@ -5000,6 +5060,26 @@ void engine_dump_snapshot(struct engine *e) {
   if (e->verbose) message("writing snapshot at t=%e.", e->time);
 #endif
 
+  /* char filename[100]; */
+  /* sprintf(filename, "cells_%04i.dat", outputCount); */
+  /* FILE *file_cell = fopen(filename, "w"); */
+  
+  /* for(int i=0; i<e->s->nr_cells; ++i) { */
+
+  /*   const struct cell *c = &e->s->cells_top[i]; */
+
+  /*   if(c->count > 0){ */
+  /*     fprintf(file_cell, "%e %e %e %e %d %d %lld %lld\n", */
+  /* 	      c->loc[0], c->loc[1], c->width[0], c->width[1], */
+  /* 	      c->count, c->split, */
+  /* 	      c->ti_hydro_end_min,  c->ti_hydro_end_max); */
+  /*   } */
+    
+  /* } */
+
+  /* fclose(file_cell); */
+
+  
 /* Dump... */
 #if defined(WITH_MPI)
 #if defined(HAVE_PARALLEL_HDF5)
@@ -5015,7 +5095,7 @@ void engine_dump_snapshot(struct engine *e) {
   write_output_single(e, e->snapshotBaseName, e->internal_units,
                       e->snapshotUnits);
 #endif
-
+		
   e->dump_snapshot = 0;
 
   clocks_gettime(&time2);
diff --git a/src/hydro/Gizmo/hydro_io.h b/src/hydro/Gizmo/hydro_io.h
index 9d6acf4155f02dc8caaa92be5366389ebb5ecaef..2a12b2c4c46ea5ab1713449728392473b45070de 100644
--- a/src/hydro/Gizmo/hydro_io.h
+++ b/src/hydro/Gizmo/hydro_io.h
@@ -131,7 +131,7 @@ void convert_part_pos(const struct engine* e, const struct part* p,
 void hydro_write_particles(struct part* parts, struct io_props* list,
                            int* num_fields) {
 
-  *num_fields = 10;
+  *num_fields = 11;
 
   /* List what we want to write */
   list[0] = io_make_output_field_convert_part(
@@ -155,6 +155,8 @@ void hydro_write_particles(struct part* parts, struct io_props* list,
                                  parts, primitives.P);
   list[9] = io_make_output_field_convert_part(
       "TotEnergy", FLOAT, 1, UNIT_CONV_ENERGY, parts, convert_Etot);
+
+  list[10] = io_make_output_field("Time_bin", CHAR, 1, UNIT_CONV_NO_UNITS, parts, time_bin);
 }
 
 /**
diff --git a/src/runner_doiact.h b/src/runner_doiact.h
index e4521b9dca9251da1a05b8c7b79aca45034cde76..632572bc9e3abb803f535fad43cf6d062ff998de 100644
--- a/src/runner_doiact.h
+++ b/src/runner_doiact.h
@@ -862,6 +862,9 @@ void DOPAIR1(struct runner *r, struct cell *ci, struct cell *cj, const int sid,
       struct part *restrict pi = &parts_i[sort_i[pid].i];
       const float hi = pi->h;
 
+      //MATTHIEU
+      if(hi > ci->h_max) error("Invalid ci->h_max");
+      
       /* Skip inactive particles */
       if (!part_is_active(pi, e)) continue;
 
@@ -942,6 +945,10 @@ void DOPAIR1(struct runner *r, struct cell *ci, struct cell *cj, const int sid,
       struct part *pj = &parts_j[sort_j[pjd].i];
       const float hj = pj->h;
 
+      //MATTHIEU
+      if(hj > cj->h_max) error("Invalid ci->h_max");
+
+      
       /* Skip inactive particles */
       if (!part_is_active(pj, e)) continue;
 
diff --git a/src/serial_io.c b/src/serial_io.c
index 7f87c0183d637e8266f80e208783411664274edd..29c218bdd0214ab96561ec5484cc728144f58fc9 100644
--- a/src/serial_io.c
+++ b/src/serial_io.c
@@ -51,6 +51,8 @@
 #include "units.h"
 #include "xmf.h"
 
+int outputCount = 0;
+
 /*-----------------------------------------------------------------------------
  * Routines reading an IC file
  *-----------------------------------------------------------------------------*/
@@ -709,7 +711,7 @@ void write_output_serial(struct engine* e, const char* baseName,
   struct gpart* gparts = e->s->gparts;
   struct gpart* dmparts = NULL;
   struct spart* sparts = e->s->sparts;
-  static int outputCount = 0;
+  //static int outputCount = 0;
   FILE* xmfFile = 0;
 
   /* Number of unassociated gparts */
diff --git a/src/single_io.c b/src/single_io.c
index 3cf1d313dc5ed03073e794695d077f1f71e5b30a..252ff8cbee62d5259c51b6ec97a5296057ee74fe 100644
--- a/src/single_io.c
+++ b/src/single_io.c
@@ -50,6 +50,8 @@
 #include "units.h"
 #include "xmf.h"
 
+int outputCount = 0;
+
 /*-----------------------------------------------------------------------------
  * Routines reading an IC file
  *-----------------------------------------------------------------------------*/
@@ -574,7 +576,7 @@ void write_output_single(struct engine* e, const char* baseName,
   struct gpart* gparts = e->s->gparts;
   struct gpart* dmparts = NULL;
   struct spart* sparts = e->s->sparts;
-  static int outputCount = 0;
+  //static int outputCount = 0;
 
   /* Number of unassociated gparts */
   const size_t Ndm = Ntot > 0 ? Ntot - (Ngas + Nstars) : 0;
diff --git a/src/space.c b/src/space.c
index 8a07e2e32d604b5e7a7c209d0990cc813ab38d85..09caeee8f86dfe2952f39141e8c0d24481c825e4 100644
--- a/src/space.c
+++ b/src/space.c
@@ -2635,10 +2635,6 @@ void space_first_init_parts(struct space *s) {
     p[i].v[1] = p[i].v[2] = 0.f;
 #endif
 
-    double temp = p[i].v[0];
-    p[i].v[0] = p[i].v[1];
-    p[i].v[1] = temp;
-    
     hydro_first_init_part(&p[i], &xp[i]);
 
 #ifdef SWIFT_DEBUG_CHECKS