diff --git a/src/space.h b/src/space.h
index 8069721a71b9f47664290b6e34eef726efdb47c8..1da8e952c9c0694610ab279aa5b90a349ea6e739 100644
--- a/src/space.h
+++ b/src/space.h
@@ -85,8 +85,8 @@ struct space {
   struct gpart *gparts;
 
   /* The total number of parts in the space. */
-  int nr_parts, size_parts;
-  int nr_gparts, size_gparts;
+  size_t nr_parts, size_parts;
+  size_t nr_gparts, size_gparts;
 
   /* Is the space periodic? */
   int periodic;
@@ -102,12 +102,13 @@ struct space {
 
   /* Buffers for parts that we will receive from foreign cells. */
   struct part *parts_foreign;
-  int nr_parts_foreign, size_parts_foreign;
+  size_t nr_parts_foreign, size_parts_foreign;
 };
 
 /* Interval stack necessary for parallel particle sorting. */
 struct qstack {
-  volatile int i, j, min, max;
+  volatile size_t i, j;
+  volatile int min, max;
   volatile int ready;
 };
 struct parallel_sort {
@@ -121,13 +122,13 @@ struct parallel_sort {
 extern struct parallel_sort space_sort_struct;
 
 /* function prototypes. */
-void space_parts_sort(struct space *s, int *ind, int N, int min, int max,
+void space_parts_sort(struct space *s, size_t *ind, size_t N, int min, int max,
                       int verbose);
-void space_gparts_sort(struct gpart *gparts, int *ind, int N, int min, int max);
+void space_gparts_sort(struct gpart *gparts, size_t *ind, size_t N, int min, int max);
 struct cell *space_getcell(struct space *s);
 int space_getsid(struct space *s, struct cell **ci, struct cell **cj,
                  double *shift);
-void space_init(struct space *s, double dim[3], struct part *parts, int N,
+void space_init(struct space *s, double dim[3], struct part *parts, size_t N,
                 int periodic, double h_max, int verbose);
 void space_map_cells_pre(struct space *s, int full,
                          void (*fun)(struct cell *c, void *data), void *data);