diff --git a/examples/main.c b/examples/main.c
index 32d7651049fe25c29685ab801e58b0126d5db67a..f490465822859bc991eb31b9a857753c85934d6a 100644
--- a/examples/main.c
+++ b/examples/main.c
@@ -679,6 +679,9 @@ int main(int argc, char *argv[]) {
       for (size_t k = 0; k < Ngpart; ++k)
         if (gparts[k].type == swift_type_gas) error("Linking problem");
     }
+
+    /* Check that the other links are correctly set */
+    part_verify_links(parts, gparts, sparts, Ngas, Ngpart, Nspart, 1);
 #endif
 
     /* Get the total number of particles across all nodes. */
diff --git a/src/common_io.c b/src/common_io.c
index 7ab96990d30d0731b2b9f13408525d850fb34baa..19adc57fbd51972336840669dab473f846d23dee 100644
--- a/src/common_io.c
+++ b/src/common_io.c
@@ -708,7 +708,7 @@ void io_duplicate_hydro_gparts_mapper(void* restrict data, int Ngas,
     gparts[i + Ndm].type = swift_type_gas;
 
     /* Link the particles */
-    gparts[i + Ndm].id_or_neg_offset = -i;
+    gparts[i + Ndm].id_or_neg_offset = -(long long)(offset + i);
     parts[i].gpart = &gparts[i + Ndm];
   }
 }
@@ -764,7 +764,7 @@ void io_duplicate_hydro_sparts_mapper(void* restrict data, int Nstars,
     gparts[i + Ndm].type = swift_type_star;
 
     /* Link the particles */
-    gparts[i + Ndm].id_or_neg_offset = -i;
+    gparts[i + Ndm].id_or_neg_offset = -(long long)(offset + i);
     sparts[i].gpart = &gparts[i + Ndm];
   }
 }
diff --git a/src/scheduler.c b/src/scheduler.c
index 072235be1807db972208514739409cdb1e76c0d6..151304293749a29abe9bd9680d8f8f81bc845884 100644
--- a/src/scheduler.c
+++ b/src/scheduler.c
@@ -1435,7 +1435,8 @@ void scheduler_enqueue(struct scheduler *s, struct task *t) {
     switch (t->type) {
       case task_type_self:
       case task_type_sub_self:
-        if (t->subtype == task_subtype_grav || t->subtype == task_subtype_external_grav)
+        if (t->subtype == task_subtype_grav ||
+            t->subtype == task_subtype_external_grav)
           qid = t->ci->super_gravity->owner;
         else
           qid = t->ci->super_hydro->owner;