-static d0_bignum_t *zero, *one, *four, *temp0, *temp1, *temp2, *temp3, *temp4;
+// safe to use
+static d0_bignum_t *zero, *one, *four;
+
+static d0_bignum_t *temp0, *temp1, *temp2, *temp3, *temp4;
+static void *tempmutex = NULL; // hold this mutex when using temp0 to temp4
+#define USINGTEMPS() int locked = 0
+#define LOCKTEMPS() do { if(!locked) d0_lockmutex(tempmutex); locked = 1; } while(0)
+#define UNLOCKTEMPS() do { if(locked) d0_unlockmutex(tempmutex); locked = 0; } while(0);