diff --git a/examples/EAGLE_ICs/EAGLE_25/README b/examples/EAGLE_ICs/EAGLE_25/README
new file mode 100644
index 0000000000000000000000000000000000000000..abe441a5f2f1edb32dfa638f737b775c473524fe
--- /dev/null
+++ b/examples/EAGLE_ICs/EAGLE_25/README
@@ -0,0 +1,3 @@
+Initial conditions corresponding to the 25 Mpc volume
+of the EAGLE suite. The ICs only contain DM particles. The
+gas particles will be generated in SWIFT.
diff --git a/examples/EAGLE_ICs/EAGLE_25/eagle_25.yml b/examples/EAGLE_ICs/EAGLE_25/eagle_25.yml
new file mode 100644
index 0000000000000000000000000000000000000000..ac8be3ecec4e56af2e910bb104038b033af59078
--- /dev/null
+++ b/examples/EAGLE_ICs/EAGLE_25/eagle_25.yml
@@ -0,0 +1,115 @@
+# Define the system of units to use internally. 
+InternalUnitSystem:
+  UnitMass_in_cgs:     1.98848e43    # 10^10 M_sun in grams
+  UnitLength_in_cgs:   3.08567758e24 # Mpc in centimeters
+  UnitVelocity_in_cgs: 1e5           # km/s in centimeters per second
+  UnitCurrent_in_cgs:  1             # Amperes
+  UnitTemp_in_cgs:     1             # Kelvin
+
+# Cosmological parameters
+Cosmology:
+  h:              0.6777        # Reduced Hubble constant
+  a_begin:        0.0078125     # Initial scale-factor of the simulation
+  a_end:          1.0           # Final scale factor of the simulation
+  Omega_m:        0.307         # Matter density parameter
+  Omega_lambda:   0.693         # Dark-energy density parameter
+  Omega_b:        0.0455        # Baryon density parameter
+
+# Parameters governing the time integration
+TimeIntegration:
+  dt_min:     1e-10 # The minimal time-step size of the simulation (in internal units).
+  dt_max:     1e-2  # The maximal time-step size of the simulation (in internal units).
+  
+# Parameters governing the snapshots
+Snapshots:
+  basename:            eagle # Common part of the name of output files
+  scale_factor_first:  0.05
+  delta_time:          1.02
+
+# Parameters governing the conserved quantities statistics
+Statistics:
+  delta_time:           1.02
+  scale_factor_first:   0.05
+
+# Parameters for the self-gravity scheme
+Gravity:
+  eta:                    0.025     # Constant dimensionless multiplier for time integration.
+  theta:                  0.7       # Opening angle (Multipole acceptance criterion)
+  comoving_softening:     0.0026994 # Comoving softening length (in internal units).
+  max_physical_softening: 0.0007    # Physical softening length (in internal units).
+  mesh_side_length:       128
+  
+# Parameters for the hydrodynamics scheme
+SPH:
+  resolution_eta:        1.2348   # Target smoothing length in units of the mean inter-particle separation (1.2348 == 48Ngbs with the cubic spline kernel).
+  h_min_ratio:           0.1      # Minimal smoothing in units of softening.
+  CFL_condition:         0.1      # Courant-Friedrich-Levy condition for time integration.
+  minimal_temperature:   100.0    # (internal units)
+  initial_temperature:   268.7
+
+Scheduler:
+  max_top_level_cells:   16
+  cell_split_size:       100
+  tasks_per_cell:        5
+
+Restarts:
+  delta_hours:  1.0
+
+# Parameters related to the initial conditions
+InitialConditions:
+  file_name:  EAGLE_L0025N0376_ICs.hdf5
+  periodic:   1
+  cleanup_h_factors: 1               # Remove the h-factors inherited from Gadget
+  cleanup_velocity_factors: 1        # Remove the sqrt(a) factor in the velocities inherited from Gadget
+  generate_gas_in_ics: 1             # Generate gas particles from the DM-only ICs
+  cleanup_smoothing_lengths: 1       # Since we generate gas, make use of the (expensive) cleaning-up procedure.
+
+# Impose primoridal metallicity
+EAGLEChemistry:
+  init_abundance_metal:     0.
+  init_abundance_Hydrogen:  0.752
+  init_abundance_Helium:    0.248
+  init_abundance_Carbon:    0.0
+  init_abundance_Nitrogen:  0.0
+  init_abundance_Oxygen:    0.0
+  init_abundance_Neon:      0.0
+  init_abundance_Magnesium: 0.0
+  init_abundance_Silicon:   0.0
+  init_abundance_Iron:      0.0
+
+# EAGLE cooling parameters
+EAGLECooling:
+  dir_name:                ./coolingtables/
+  H_reion_z:               11.5 
+  H_reion_eV_p_H:          2.0
+  He_reion_z_centre:       3.5
+  He_reion_z_sigma:        0.5
+  He_reion_eV_p_H:         2.0
+
+# EAGLE star formation parameters
+EAGLEStarFormation:
+  EOS_density_norm_H_p_cm3:          0.1       # Physical density used for the normalisation of the EOS assumed for the star-forming gas in Hydrogen atoms per cm^3.
+  EOS_temperature_norm_K:            8000      # Temperature om the polytropic EOS assumed for star-forming gas at the density normalisation in Kelvin.
+  EOS_gamma_effective:               1.3333333 # Slope the of the polytropic EOS assumed for the star-forming gas.
+  KS_normalisation:                  1.515e-4  # The normalization of the Kennicutt-Schmidt law in Msun / kpc^2 / yr.
+  KS_exponent:                       1.4       # The exponent of the Kennicutt-Schmidt law.
+  KS_min_over_density:               57.7      # The over-density above which star-formation is allowed.
+  KS_high_density_threshold_H_p_cm3: 1e3       # Hydrogen number density above which the Kennicut-Schmidt law changes slope in Hydrogen atoms per cm^3.
+  KS_high_density_exponent:          2.0       # Slope of the Kennicut-Schmidt law above the high-density threshold.
+  KS_temperature_margin_dex:         0.5       # Logarithm base 10 of the maximal temperature difference above the EOS allowed to form stars.
+  threshold_norm_H_p_cm3:            0.1       # Normalisation of the metal-dependant density threshold for star formation in Hydrogen atoms per cm^3.
+  threshold_Z0:                      0.002     # Reference metallicity (metal mass fraction) for the metal-dependant threshold for star formation.
+  threshold_slope:                   -0.64     # Slope of the metal-dependant star formation threshold
+  threshold_max_density_H_p_cm3:     10.0      # Maximal density of the metal-dependant density threshold for star formation in Hydrogen atoms per cm^3.
+  
+# Parameters for the EAGLE "equation of state"
+EAGLEEntropyFloor:
+  Jeans_density_threshold_H_p_cm3: 0.1       # Physical density above which the EAGLE Jeans limiter entropy floor kicks in expressed in Hydrogen atoms per cm^3.
+  Jeans_over_density_threshold:    10.       # Overdensity above which the EAGLE Jeans limiter entropy floor can kick in.
+  Jeans_temperature_norm_K:        8000      # Temperature of the EAGLE Jeans limiter entropy floor at the density threshold expressed in Kelvin.
+  Jeans_gamma_effective:           1.3333333 # Slope the of the EAGLE Jeans limiter entropy floor
+  Cool_density_threshold_H_p_cm3: 1e-5       # Physical density above which the EAGLE Cool limiter entropy floor kicks in expressed in Hydrogen atoms per cm^3.
+  Cool_over_density_threshold:    10.        # Overdensity above which the EAGLE Cool limiter entropy floor can kick in.
+  Cool_temperature_norm_K:        8000       # Temperature of the EAGLE Cool limiter entropy floor at the density threshold expressed in Kelvin.
+  Cool_gamma_effective:           1.         # Slope the of the EAGLE Cool limiter entropy floor
+
diff --git a/examples/EAGLE_ICs/EAGLE_25/getIC.sh b/examples/EAGLE_ICs/EAGLE_25/getIC.sh
new file mode 100755
index 0000000000000000000000000000000000000000..ad07fdb46633f86e8f7ffd63f5468f5203c6196c
--- /dev/null
+++ b/examples/EAGLE_ICs/EAGLE_25/getIC.sh
@@ -0,0 +1,2 @@
+#!/bin/bash
+wget http://virgodb.cosma.dur.ac.uk/swift-webstorage/ICs/EAGLE_ICs/EAGLE_L0025N0376_ICs.hdf5
diff --git a/examples/EAGLE_ICs/EAGLE_25/run.sh b/examples/EAGLE_ICs/EAGLE_25/run.sh
new file mode 100755
index 0000000000000000000000000000000000000000..8b317183d850d5048253fedb8db7e24edd9c02da
--- /dev/null
+++ b/examples/EAGLE_ICs/EAGLE_25/run.sh
@@ -0,0 +1,11 @@
+#!/bin/bash
+
+ # Generate the initial conditions if they are not present.
+if [ ! -e EAGLE_L0025N0376_ICs.hdf5 ]
+then
+    echo "Fetching initial conditions for the EAGLE 25Mpc example..."
+    ./getIC.sh
+fi
+
+../../swift --cosmology --hydro --self-gravity --stars --threads=16 eagle_25.yml 2>&1 | tee output.log
+
diff --git a/examples/EAGLE_ICs/EAGLE_50/README b/examples/EAGLE_ICs/EAGLE_50/README
new file mode 100644
index 0000000000000000000000000000000000000000..0d2032b73069aa903bbcc2fae1d0fa0d3f7c6090
--- /dev/null
+++ b/examples/EAGLE_ICs/EAGLE_50/README
@@ -0,0 +1,3 @@
+Initial conditions corresponding to the 50 Mpc volume
+of the EAGLE suite. The ICs only contain DM particles. The
+gas particles will be generated in SWIFT.
diff --git a/examples/EAGLE_ICs/EAGLE_50/eagle_50.yml b/examples/EAGLE_ICs/EAGLE_50/eagle_50.yml
new file mode 100644
index 0000000000000000000000000000000000000000..528f11f763274b8d793a525201712f1fb6603e4a
--- /dev/null
+++ b/examples/EAGLE_ICs/EAGLE_50/eagle_50.yml
@@ -0,0 +1,115 @@
+# Define the system of units to use internally. 
+InternalUnitSystem:
+  UnitMass_in_cgs:     1.98848e43    # 10^10 M_sun in grams
+  UnitLength_in_cgs:   3.08567758e24 # Mpc in centimeters
+  UnitVelocity_in_cgs: 1e5           # km/s in centimeters per second
+  UnitCurrent_in_cgs:  1             # Amperes
+  UnitTemp_in_cgs:     1             # Kelvin
+
+# Cosmological parameters
+Cosmology:
+  h:              0.6777        # Reduced Hubble constant
+  a_begin:        0.0078125     # Initial scale-factor of the simulation
+  a_end:          1.0           # Final scale factor of the simulation
+  Omega_m:        0.307         # Matter density parameter
+  Omega_lambda:   0.693         # Dark-energy density parameter
+  Omega_b:        0.0455        # Baryon density parameter
+
+# Parameters governing the time integration
+TimeIntegration:
+  dt_min:     1e-10 # The minimal time-step size of the simulation (in internal units).
+  dt_max:     1e-2  # The maximal time-step size of the simulation (in internal units).
+  
+# Parameters governing the snapshots
+Snapshots:
+  basename:            eagle # Common part of the name of output files
+  scale_factor_first:  0.05
+  delta_time:          1.02
+
+# Parameters governing the conserved quantities statistics
+Statistics:
+  delta_time:           1.02
+  scale_factor_first:   0.05
+
+# Parameters for the self-gravity scheme
+Gravity:
+  eta:                    0.025     # Constant dimensionless multiplier for time integration.
+  theta:                  0.7       # Opening angle (Multipole acceptance criterion)
+  comoving_softening:     0.0026994 # Comoving softening length (in internal units).
+  max_physical_softening: 0.0007    # Physical softening length (in internal units).
+  mesh_side_length:       256
+  
+# Parameters for the hydrodynamics scheme
+SPH:
+  resolution_eta:        1.2348   # Target smoothing length in units of the mean inter-particle separation (1.2348 == 48Ngbs with the cubic spline kernel).
+  h_min_ratio:           0.1      # Minimal smoothing in units of softening.
+  CFL_condition:         0.1      # Courant-Friedrich-Levy condition for time integration.
+  minimal_temperature:   100.0    # (internal units)
+  initial_temperature:   268.7
+
+Scheduler:
+  max_top_level_cells:   32
+  cell_split_size:       100
+  tasks_per_cell:        5
+
+Restarts:
+  delta_hours:  1.0
+
+# Parameters related to the initial conditions
+InitialConditions:
+  file_name:  EAGLE_L0050N0752_ICs.hdf5
+  periodic:   1
+  cleanup_h_factors: 1               # Remove the h-factors inherited from Gadget
+  cleanup_velocity_factors: 1        # Remove the sqrt(a) factor in the velocities inherited from Gadget
+  generate_gas_in_ics: 1             # Generate gas particles from the DM-only ICs
+  cleanup_smoothing_lengths: 1       # Since we generate gas, make use of the (expensive) cleaning-up procedure.
+
+# Impose primoridal metallicity
+EAGLEChemistry:
+  init_abundance_metal:     0.
+  init_abundance_Hydrogen:  0.752
+  init_abundance_Helium:    0.248
+  init_abundance_Carbon:    0.0
+  init_abundance_Nitrogen:  0.0
+  init_abundance_Oxygen:    0.0
+  init_abundance_Neon:      0.0
+  init_abundance_Magnesium: 0.0
+  init_abundance_Silicon:   0.0
+  init_abundance_Iron:      0.0
+
+# EAGLE cooling parameters
+EAGLECooling:
+  dir_name:                ./coolingtables/
+  H_reion_z:               11.5 
+  H_reion_eV_p_H:          2.0
+  He_reion_z_centre:       3.5
+  He_reion_z_sigma:        0.5
+  He_reion_eV_p_H:         2.0
+
+# EAGLE star formation parameters
+EAGLEStarFormation:
+  EOS_density_norm_H_p_cm3:          0.1       # Physical density used for the normalisation of the EOS assumed for the star-forming gas in Hydrogen atoms per cm^3.
+  EOS_temperature_norm_K:            8000      # Temperature om the polytropic EOS assumed for star-forming gas at the density normalisation in Kelvin.
+  EOS_gamma_effective:               1.3333333 # Slope the of the polytropic EOS assumed for the star-forming gas.
+  KS_normalisation:                  1.515e-4  # The normalization of the Kennicutt-Schmidt law in Msun / kpc^2 / yr.
+  KS_exponent:                       1.4       # The exponent of the Kennicutt-Schmidt law.
+  KS_min_over_density:               57.7      # The over-density above which star-formation is allowed.
+  KS_high_density_threshold_H_p_cm3: 1e3       # Hydrogen number density above which the Kennicut-Schmidt law changes slope in Hydrogen atoms per cm^3.
+  KS_high_density_exponent:          2.0       # Slope of the Kennicut-Schmidt law above the high-density threshold.
+  KS_temperature_margin_dex:         0.5       # Logarithm base 10 of the maximal temperature difference above the EOS allowed to form stars.
+  threshold_norm_H_p_cm3:            0.1       # Normalisation of the metal-dependant density threshold for star formation in Hydrogen atoms per cm^3.
+  threshold_Z0:                      0.002     # Reference metallicity (metal mass fraction) for the metal-dependant threshold for star formation.
+  threshold_slope:                   -0.64     # Slope of the metal-dependant star formation threshold
+  threshold_max_density_H_p_cm3:     10.0      # Maximal density of the metal-dependant density threshold for star formation in Hydrogen atoms per cm^3.
+  
+# Parameters for the EAGLE "equation of state"
+EAGLEEntropyFloor:
+  Jeans_density_threshold_H_p_cm3: 0.1       # Physical density above which the EAGLE Jeans limiter entropy floor kicks in expressed in Hydrogen atoms per cm^3.
+  Jeans_over_density_threshold:    10.       # Overdensity above which the EAGLE Jeans limiter entropy floor can kick in.
+  Jeans_temperature_norm_K:        8000      # Temperature of the EAGLE Jeans limiter entropy floor at the density threshold expressed in Kelvin.
+  Jeans_gamma_effective:           1.3333333 # Slope the of the EAGLE Jeans limiter entropy floor
+  Cool_density_threshold_H_p_cm3: 1e-5       # Physical density above which the EAGLE Cool limiter entropy floor kicks in expressed in Hydrogen atoms per cm^3.
+  Cool_over_density_threshold:    10.        # Overdensity above which the EAGLE Cool limiter entropy floor can kick in.
+  Cool_temperature_norm_K:        8000       # Temperature of the EAGLE Cool limiter entropy floor at the density threshold expressed in Kelvin.
+  Cool_gamma_effective:           1.         # Slope the of the EAGLE Cool limiter entropy floor
+
diff --git a/examples/EAGLE_ICs/EAGLE_50/getIC.sh b/examples/EAGLE_ICs/EAGLE_50/getIC.sh
new file mode 100755
index 0000000000000000000000000000000000000000..9c16c69eb7979e66d291134642e4fe3d39314774
--- /dev/null
+++ b/examples/EAGLE_ICs/EAGLE_50/getIC.sh
@@ -0,0 +1,2 @@
+#!/bin/bash
+wget http://virgodb.cosma.dur.ac.uk/swift-webstorage/ICs/EAGLE_ICs/EAGLE_L0050N0752_ICs.hdf5
diff --git a/examples/EAGLE_ICs/EAGLE_50/run.sh b/examples/EAGLE_ICs/EAGLE_50/run.sh
new file mode 100755
index 0000000000000000000000000000000000000000..3ef38da33fe1cc820e3ee5e7afb620e7e9109196
--- /dev/null
+++ b/examples/EAGLE_ICs/EAGLE_50/run.sh
@@ -0,0 +1,11 @@
+#!/bin/bash
+
+ # Generate the initial conditions if they are not present.
+if [ ! -e EAGLE_L0050N0752_ICs.hdf5 ]
+then
+    echo "Fetching initial conditions for the EAGLE 50Mpc example..."
+    ./getIC.sh
+fi
+
+../../swift --cosmology --hydro --self-gravity --stars --threads=16 eagle_50.yml 2>&1 | tee output.log
+
diff --git a/src/cell.c b/src/cell.c
index 25ee6a747c91c37ed41de7e38b5696864513e83c..6ed5b6f9dc5084e4c48a35af5a0649e61c5be086 100644
--- a/src/cell.c
+++ b/src/cell.c
@@ -1600,6 +1600,8 @@ void cell_reset_task_counters(struct cell *c) {
 #ifdef SWIFT_DEBUG_CHECKS
   for (int t = 0; t < task_type_count; ++t) c->tasks_executed[t] = 0;
   for (int t = 0; t < task_subtype_count; ++t) c->subtasks_executed[t] = 0;
+  for (int k = 0; k < 8; ++k)
+    if (c->progeny[k] != NULL) cell_reset_task_counters(c->progeny[k]);
 #else
   error("Calling debugging code without debugging flag activated.");
 #endif
@@ -3574,12 +3576,34 @@ int cell_unskip_stars_tasks(struct cell *c, struct scheduler *s) {
     const int cj_nodeID = nodeID;
 #endif
 
-    if ((ci_active && cj_nodeID == nodeID) ||
-        (cj_active && ci_nodeID == nodeID)) {
+    if (t->type == task_type_self && ci_active) {
       scheduler_activate(s, t);
+    }
 
-      /* Nothing more to do here, all drifts and sorts activated above */
+    else if (t->type == task_type_sub_self && ci_active) {
+      scheduler_activate(s, t);
     }
+
+    else if (t->type == task_type_pair || t->type == task_type_sub_pair) {
+
+      /* We only want to activate the task if the cell is active and is
+         going to update some gas on the *local* node */
+      if ((ci_nodeID == nodeID && cj_nodeID == nodeID) &&
+          (ci_active || cj_active)) {
+
+        scheduler_activate(s, t);
+
+      } else if ((ci_nodeID == nodeID && cj_nodeID != nodeID) && (cj_active)) {
+
+        scheduler_activate(s, t);
+
+      } else if ((ci_nodeID != nodeID && cj_nodeID == nodeID) && (ci_active)) {
+
+        scheduler_activate(s, t);
+      }
+    }
+
+    /* Nothing more to do here, all drifts and sorts activated above */
   }
 
   /* Unskip all the other task types. */
diff --git a/src/engine.c b/src/engine.c
index 776bb28f7bb68920f912695803cafe113c8f2a08..8f7c2f71f4589c53ca2c0cb5c8824ebdba001bf2 100644
--- a/src/engine.c
+++ b/src/engine.c
@@ -1034,7 +1034,8 @@ void engine_repartition(struct engine *e) {
 
   /* Partitioning requires copies of the particles, so we need to reduce the
    * memory in use to the minimum, we can free the sorting indices and the
-   * tasks as these will be regenerated at the next rebuild. */
+   * tasks as these will be regenerated at the next rebuild. Also the foreign
+   * particle arrays can go as these will be regenerated in proxy exchange. */
 
   /* Sorting indices. */
   if (e->s->cells_top != NULL) space_free_cells(e->s);
@@ -1042,6 +1043,9 @@ void engine_repartition(struct engine *e) {
   /* Task arrays. */
   scheduler_free_tasks(&e->sched);
 
+  /* Foreign parts. */
+  space_free_foreign_parts(e->s);
+
   /* Now comes the tricky part: Exchange particles between all nodes.
      This is done in two steps, first allreducing a matrix of
      how many particles go from where to where, then re-allocating
diff --git a/src/engine_marktasks.c b/src/engine_marktasks.c
index 9b34b3ea95a9ae8bc848a90113647b3e68b121b1..277c9560318104d7b6d28696d751ee89db26b467 100644
--- a/src/engine_marktasks.c
+++ b/src/engine_marktasks.c
@@ -309,11 +309,25 @@ void engine_marktasks_mapper(void *map_data, int num_elements,
       }
 
       /* Stars feedback */
-      else if ((t_subtype == task_subtype_stars_feedback) &&
-               ((ci_active_stars && ci_nodeID == nodeID) ||
-                (cj_active_stars && cj_nodeID == nodeID))) {
+      else if (t_subtype == task_subtype_stars_feedback) {
 
-        scheduler_activate(s, t);
+        /* We only want to activate the task if the cell is active and is
+           going to update some gas on the *local* node */
+        if ((ci_nodeID == nodeID && cj_nodeID == nodeID) &&
+            (ci_active_stars || cj_active_stars)) {
+
+          scheduler_activate(s, t);
+
+        } else if ((ci_nodeID == nodeID && cj_nodeID != nodeID) &&
+                   (cj_active_stars)) {
+
+          scheduler_activate(s, t);
+
+        } else if ((ci_nodeID != nodeID && cj_nodeID == nodeID) &&
+                   (ci_active_stars)) {
+
+          scheduler_activate(s, t);
+        }
       }
 
       /* Gravity */
diff --git a/src/runner.c b/src/runner.c
index 50cbad59b0b5bcae6611e71635e971ef6c761adf..b390156a8f833de6844924d89f129b49e51e977c 100644
--- a/src/runner.c
+++ b/src/runner.c
@@ -147,6 +147,7 @@ void runner_do_stars_ghost(struct runner *r, struct cell *c, int timer) {
   TIMER_TIC;
 
   /* Anything to do here? */
+  if (c->stars.count == 0) return;
   if (!cell_is_active_stars(c, e)) return;
 
   /* Recurse? */
diff --git a/src/runner_doiact_stars.h b/src/runner_doiact_stars.h
index e56d3b9460381e8408f370cae33e64fb93ecd541..6b8b12ad966d6ee1271ae8e5d48a0e2b5d9166c4 100644
--- a/src/runner_doiact_stars.h
+++ b/src/runner_doiact_stars.h
@@ -1444,7 +1444,7 @@ void DOSUB_SUBSET_STARS(struct runner *r, struct cell *ci, struct spart *sparts,
     }
 
     /* Otherwise, compute the pair directly. */
-    else if (cell_is_active_stars(ci, e)) {
+    else if (cell_is_active_stars(ci, e) && cj->hydro.count > 0) {
 
       /* Do any of the cells need to be drifted first? */
       if (cell_is_active_stars(ci, e)) {
diff --git a/src/space.c b/src/space.c
index 30cfea8e721b17dd332941167cf3c9c8c64c3788..3e51e9f11178f6ca57e612db3ed9aa4ac8fd0ead 100644
--- a/src/space.c
+++ b/src/space.c
@@ -294,6 +294,8 @@ void space_rebuild_recycle_mapper(void *map_data, int num_elements,
 
 /**
  * @brief Free up any allocated cells.
+ *
+ * @param s The #space.
  */
 void space_free_cells(struct space *s) {
 
@@ -308,6 +310,32 @@ void space_free_cells(struct space *s) {
             clocks_getunit());
 }
 
+/**
+ * @brief Free any memory in use for foreign particles.
+ *
+ * @param s The #space.
+ */
+void space_free_foreign_parts(struct space *s) {
+
+#ifdef WITH_MPI
+  if (s->parts_foreign != NULL) {
+    free(s->parts_foreign);
+    s->size_parts_foreign = 0;
+    s->parts_foreign = NULL;
+  }
+  if (s->gparts_foreign != NULL) {
+    free(s->gparts_foreign);
+    s->size_gparts_foreign = 0;
+    s->gparts_foreign = NULL;
+  }
+  if (s->sparts_foreign != NULL) {
+    free(s->sparts_foreign);
+    s->size_sparts_foreign = 0;
+    s->sparts_foreign = NULL;
+  }
+#endif
+}
+
 /**
  * @brief Re-build the top-level cell grid.
  *
diff --git a/src/space.h b/src/space.h
index 924c3efaf81f88cb82a8c23707d42883832aa071..272ee41c3569cf3580678c0de885a41075f0e1b4 100644
--- a/src/space.h
+++ b/src/space.h
@@ -329,6 +329,8 @@ void space_reset_task_counters(struct space *s);
 void space_clean(struct space *s);
 void space_free_cells(struct space *s);
 
+void space_free_foreign_parts(struct space *s);
+
 void space_struct_dump(struct space *s, FILE *stream);
 void space_struct_restore(struct space *s, FILE *stream);
 void space_write_cell_hierarchy(const struct space *s);
diff --git a/tools/combine_ics.py b/tools/combine_ics.py
index 64f255a61934bc3667fdb5934f74a206013e4872..d864c67d7d44fb6550e3cd858c50bb660d6126ca 100755
--- a/tools/combine_ics.py
+++ b/tools/combine_ics.py
@@ -41,7 +41,7 @@ import numpy as np
 # Store the compression level
 gzip_level = 4
 if len(sys.argv) > 3:
-    gzip_level = sys.argv[3]
+    gzip_level = int(sys.argv[3])
 
 # First, we need to collect some information from the master file
 main_file_name = str(sys.argv[1])[:-7]