Index: libpolys/polys/flint_mpoly.cc
===================================================================
--- libpolys/polys/flint_mpoly.cc	(revision 690c98d2dc9aa6f233ef1da705b30c910d6e9898)
+++ libpolys/polys/flint_mpoly.cc	(revision 3f94cbdb24129f0002a999ab5fb63a34f0fc933d)
@@ -241,7 +241,7 @@
     fmpq_t content;
 
-    convert_sing_to_fmpq_mpoly_base(slong num_threads_, fmpq_mpoly_struct * res_,
-                             const fmpq_mpoly_ctx_struct * ctx_, const ring r_, poly p)
-      : num_threads(num_threads_),
+    convert_sing_to_fmpq_mpoly_base(fmpq_mpoly_struct * res_,
+                     const fmpq_mpoly_ctx_struct * ctx_, const ring r_, poly p)
+      : num_threads(0),
         res(res_),
         ctx(ctx_),
@@ -428,7 +428,11 @@
     thread_pool_handle * handles;
     slong num_handles;
-    slong thread_limit = 1000;
-
-    /* get workers */
+    slong thread_limit = 1000; // TODO: should be paramter to this function
+
+    /* the constructor works out the length of p and sets some markers */
+    convert_sing_to_fmpq_mpoly_base base(res, ctx, r, p);
+
+    /* sensibly limit thread count and get workers */
+    thread_limit = FLINT_MIN(thread_limit, base.length/1024);
     handles = NULL;
     num_handles = 0;
@@ -444,8 +448,6 @@
     }
 
-    /* the constructor works out the length of p and sets some markers */
-    convert_sing_to_fmpq_mpoly_base base(num_handles + 1, res, ctx, r, p);
-
     /* fill in thread division points */
+    base.num_threads = 1 + num_handles;
     convert_sing_to_fmpq_mpoly_arg * args = new convert_sing_to_fmpq_mpoly_arg[base.num_threads];
     slong cur_idx = 0;
@@ -606,7 +608,8 @@
     thread_pool_handle * handles;
     slong num_handles;
-    slong thread_limit = 1000;
-
-    /* get workers */
+    slong thread_limit = 1000;// TODO: should be paramter to this function
+
+    /* sensibly limit threads and get workers */
+    thread_limit = FLINT_MIN(thread_limit, f->zpoly->length/1024);
     handles = NULL;
     num_handles = 0;
@@ -623,5 +626,4 @@
 
     convert_fmpq_mpoly_to_sing_base base(num_handles + 1, f, ctx, r);
-
     convert_fmpq_mpoly_to_sing_arg * args = new convert_fmpq_mpoly_to_sing_arg[base.num_threads];
     slong cur_idx = 0;
@@ -681,7 +683,7 @@
     ring r;
 
-    convert_sing_to_nmod_mpoly_base(slong num_threads_, nmod_mpoly_struct * res_,
-                            const nmod_mpoly_ctx_struct * ctx_, const ring r_, poly p)
-      : num_threads(num_threads_),
+    convert_sing_to_nmod_mpoly_base(nmod_mpoly_struct * res_,
+                     const nmod_mpoly_ctx_struct * ctx_, const ring r_, poly p)
+      : num_threads(0),
         res(res_),
         ctx(ctx_),
@@ -792,7 +794,11 @@
     thread_pool_handle * handles;
     slong num_handles;
-    slong thread_limit = 1000;
-
-    /* get workers */
+    slong thread_limit = 1000; // TODO: should be paramter to this function
+
+    /* the constructor works out the length of p and sets some markers */
+    convert_sing_to_nmod_mpoly_base base(res, ctx, r, p);
+
+    /* sensibly limit thread count and get workers */
+    thread_limit = FLINT_MIN(thread_limit, base.length/1024);
     handles = NULL;
     num_handles = 0;
@@ -808,7 +814,6 @@
     }
 
-    convert_sing_to_nmod_mpoly_base base(num_handles + 1, res, ctx, r, p);
-
     /* fill in thread division points */
+    base.num_threads = 1 + num_handles;
     convert_sing_to_nmod_mpoly_arg * args = new convert_sing_to_nmod_mpoly_arg[base.num_threads];
     slong cur_idx = 0;
@@ -921,7 +926,8 @@
     thread_pool_handle * handles;
     slong num_handles;
-    slong thread_limit = 1000;
-
-    /* get workers */
+    slong thread_limit = 1000; // TODO: should be paramter to this function
+
+    /* sensibly limit threads and get workers */
+    thread_limit = FLINT_MIN(thread_limit, f->length/1024);
     handles = NULL;
     num_handles = 0;
@@ -938,5 +944,4 @@
 
     convert_nmod_mpoly_to_sing_base base(num_handles + 1, f, ctx, r);
-
     convert_nmod_mpoly_to_sing_arg * args = new convert_nmod_mpoly_to_sing_arg[base.num_threads];
     slong cur_idx = 0;
