diff --git a/src/gravity/Default/gravity.h b/src/gravity/Default/gravity.h
index 98bc7edb4605c6958ab3e8bbcb8178d6c054a36f..93ceb3803ee457339e6f6e565c3d3f691f7d58ae 100644
--- a/src/gravity/Default/gravity.h
+++ b/src/gravity/Default/gravity.h
@@ -230,7 +230,7 @@ __attribute__((always_inline)) INLINE static void gravity_first_init_gpart(
   gravity_init_gpart(gp);
 
 #ifdef WITH_LOGGER
-  gp->last_output = 0;
+  gp->last_output = SHRT_MAX;
   gp->last_offset = 0;
 #endif
 }
diff --git a/src/gravity/Default/gravity_io.h b/src/gravity/Default/gravity_io.h
index d8fb1bb1fc15324070e7e8154f102a48f97e0227..c653e09f7ed689276357d979581ca03aadda1c93 100644
--- a/src/gravity/Default/gravity_io.h
+++ b/src/gravity/Default/gravity_io.h
@@ -130,6 +130,7 @@ INLINE static void darkmatter_write_particles(const struct gpart* gparts,
 void darkmatter_write_index(struct gpart* gparts, struct io_props* list,
 			    int* num_fields) {
 
+#ifdef WITH_LOGGER
   /* Say how much we want to read */
   *num_fields = 2;
 
@@ -139,6 +140,9 @@ void darkmatter_write_index(struct gpart* gparts, struct io_props* list,
 
   list[1] = io_make_output_field("Offset", ULONGLONG, 1,
                                  UNIT_CONV_NO_UNITS, gparts, last_offset);
+#else
+  error("Cannot write index without logger");
+#endif
 }
 
 #endif /* SWIFT_DEFAULT_GRAVITY_IO_H */
diff --git a/src/hydro/Gadget2/hydro.h b/src/hydro/Gadget2/hydro.h
index 6232f3d32784dbe5cf45fc3589a8b44826c33633..9cdb6344a6fbace79c589e8b21cdcef3458c4e5d 100644
--- a/src/hydro/Gadget2/hydro.h
+++ b/src/hydro/Gadget2/hydro.h
@@ -743,7 +743,6 @@ __attribute__((always_inline)) INLINE static void hydro_first_init_part(
     struct part *restrict p, struct xpart *restrict xp) {
 
   p->time_bin = 0;
-  p->last_offset = 0;
   xp->v_full[0] = p->v[0];
   xp->v_full[1] = p->v[1];
   xp->v_full[2] = p->v[2];
@@ -751,7 +750,11 @@ __attribute__((always_inline)) INLINE static void hydro_first_init_part(
   xp->a_grav[1] = 0.f;
   xp->a_grav[2] = 0.f;
   xp->entropy_full = p->entropy;
+
+#ifdef WITH_LOGGER
+  p->last_offset = 0;
   xp->last_output = SHRT_MAX;
+#endif
 
   hydro_reset_acceleration(p);
   hydro_init_part(p, NULL);
diff --git a/src/hydro/Gadget2/hydro_io.h b/src/hydro/Gadget2/hydro_io.h
index 1b43306bb34716fb84ed7d2b3cb963cf1bbd4893..ec99174201e7a54e1e7b69d6aff8de118563f0db 100644
--- a/src/hydro/Gadget2/hydro_io.h
+++ b/src/hydro/Gadget2/hydro_io.h
@@ -201,6 +201,7 @@ INLINE static void hydro_write_particles(const struct part* parts,
 void hydro_write_index(struct part* parts, struct io_props* list,
 		       int* num_fields) {
 
+#ifdef WITH_LOGGER
   *num_fields = 2;
 
   /* List what we want to write */
@@ -209,6 +210,10 @@ void hydro_write_index(struct part* parts, struct io_props* list,
 
   list[1] = io_make_output_field("Offset", ULONGLONG, 1,
                                  UNIT_CONV_NO_UNITS, parts, last_offset);
+#else
+  error("Cannot write index without logger");
+#endif
+  
 }
 
 
diff --git a/src/hydro/Gadget2/hydro_part.h b/src/hydro/Gadget2/hydro_part.h
index 102e6aeb7b761109215963b66c05e4044e005427..ad72d40ec0eb0e0c614c55f32fdf803041c33430 100644
--- a/src/hydro/Gadget2/hydro_part.h
+++ b/src/hydro/Gadget2/hydro_part.h
@@ -55,8 +55,10 @@ struct xpart {
   /* Additional data used to record cooling information */
   struct cooling_xpart_data cooling_data;
 
+#ifdef WITH_LOGGER
   /* Number of time step since last output */
   short int last_output;
+#endif
 
 } SWIFT_STRUCT_ALIGN;
 
@@ -93,8 +95,10 @@ struct part {
   /* Entropy time derivative */
   float entropy_dt;
 
+#ifdef WITH_LOGGER
   /* offset at last writing */
   size_t last_offset;
+#endif
 
   union {