diff --git a/src/bignum.c b/src/bignum.c
index 7b1c70fba13a290ebd48160a3c3c9e4f7cd0de78..0facc6fc8e4ff00b452699489ec219a176899f1f 100644
--- a/src/bignum.c
+++ b/src/bignum.c
@@ -2,7 +2,7 @@
 || This file is part of Pike. For copyright information see COPYRIGHT.
 || Pike is distributed under GPL, LGPL and MPL. See the file COPYING
 || for more information.
-|| $Id: bignum.c,v 1.37 2003/03/29 17:12:17 grubba Exp $
+|| $Id: bignum.c,v 1.38 2003/04/02 00:38:31 mast Exp $
 */
 
 #include "global.h"
@@ -130,11 +130,21 @@ PMOD_EXPORT void bootstrap_push_int64 (INT64 i)
     push_int(DO_NOT_WARN((INT_TYPE)i));
   }
   else
-    Pike_error ("Failed to convert large integer (Gmp.bignum not loaded).\n");
+    Pike_fatal ("Failed to convert large integer (Gmp.bignum not loaded).\n");
 }
 
 PMOD_EXPORT void (*push_int64) (INT64) = bootstrap_push_int64;
 PMOD_EXPORT int (*int64_from_bignum) (INT64 *, struct object *) = NULL;
+
+PMOD_EXPORT void hook_in_int64_funcs (
+  void (*push_int64_val)(INT64),
+  int (*int64_from_bignum_val) (INT64 *, struct object *))
+{
+  /* Assigning the pointers above directly from the Gmp module doesn't
+   * work in some cases, e.g. NT. */
+  push_int64 = push_int64_val ? push_int64_val : bootstrap_push_int64;
+  int64_from_bignum = int64_from_bignum_val;
+}
 #endif
 
 #endif /* AUTO_BIGNUM */
diff --git a/src/bignum.h b/src/bignum.h
index 6e7bebf4b48b8abc06b26f756783faf0e5e9059a..59e54b4ccc0abbd0e4efbd4520814059132afa58 100644
--- a/src/bignum.h
+++ b/src/bignum.h
@@ -2,7 +2,7 @@
 || This file is part of Pike. For copyright information see COPYRIGHT.
 || Pike is distributed under GPL, LGPL and MPL. See the file COPYING
 || for more information.
-|| $Id: bignum.h,v 1.22 2003/03/29 17:12:17 grubba Exp $
+|| $Id: bignum.h,v 1.23 2003/04/02 00:38:31 mast Exp $
 */
 
 #include "global.h"
@@ -61,6 +61,9 @@ void convert_svalue_to_bignum(struct svalue *s);
 PMOD_EXPORT void bootstrap_push_int64(INT64 i);
 PMOD_EXPORT void (*push_int64)(INT64 i);
 PMOD_EXPORT int (*int64_from_bignum) (INT64 *i, struct object *bignum);
+PMOD_EXPORT void hook_in_int64_funcs (
+  void (*push_int64_val)(INT64),
+  int (*int64_from_bignum_val) (INT64 *, struct object *));
 #else
 #define push_int64(i) push_int((INT_TYPE)(i))
 #define int64_from_bignum(I,BIGNUM)	0
diff --git a/src/modules/Gmp/mpz_glue.c b/src/modules/Gmp/mpz_glue.c
index 46347db4b1654fa83adb9cc2866cd2a73b308ade..848fb55c09647cb34da03ef15e65d136b232decb 100644
--- a/src/modules/Gmp/mpz_glue.c
+++ b/src/modules/Gmp/mpz_glue.c
@@ -2,11 +2,11 @@
 || This file is part of Pike. For copyright information see COPYRIGHT.
 || Pike is distributed under GPL, LGPL and MPL. See the file COPYING
 || for more information.
-|| $Id: mpz_glue.c,v 1.137 2003/03/29 17:14:22 grubba Exp $
+|| $Id: mpz_glue.c,v 1.138 2003/04/02 00:38:31 mast Exp $
 */
 
 #include "global.h"
-RCSID("$Id: mpz_glue.c,v 1.137 2003/03/29 17:14:22 grubba Exp $");
+RCSID("$Id: mpz_glue.c,v 1.138 2003/04/02 00:38:31 mast Exp $");
 #include "gmp_machine.h"
 #include "module.h"
 
@@ -143,11 +143,11 @@ static void gmp_push_int64 (INT64 i)
 	((SIZEOF_INT64 + SIZEOF_LONG - 1) / SIZEOF_LONG - 1)
 	/* The above is the position of the top unsigned long in the INT64. */
 	* ULONG_BITS;
-      mpz_set_ui (mpz, (i >> n) & ULONG_MAX);
+      mpz_set_ui (mpz, (unsigned long) (i >> n));
       while (n) {
 	n -= ULONG_BITS;
 	mpz_mul_2exp (mpz, mpz, ULONG_BITS);
-	mpz_add_ui (mpz, mpz, (i >> n) & ULONG_MAX);
+	mpz_add_ui (mpz, mpz, (unsigned long) (i >> n));
       }
     }
 #endif
@@ -308,11 +308,11 @@ int get_new_mpz(MP_INT *tmp, struct svalue *s,
 	  ((SIZEOF_INT_TYPE + SIZEOF_LONG - 1) / SIZEOF_LONG - 1)
 	  /* The above is the position of the top unsigned long in the INT_TYPE. */
 	  * ULONG_BITS;
-	mpz_set_ui (tmp, (i >> n) & ULONG_MAX);
+	mpz_set_ui (tmp, (unsigned long) (i >> n));
 	while (n) {
 	  n -= ULONG_BITS;
 	  mpz_mul_2exp (tmp, tmp, ULONG_BITS);
-	  mpz_add_ui (tmp, tmp, (i >> n) & ULONG_MAX);
+	  mpz_add_ui (tmp, tmp, (unsigned long) (i >> n));
 	}
       }
 #endif
@@ -1724,8 +1724,7 @@ PIKE_MODULE_EXIT
     mpz_clear (mpz_int_type_min);
 #ifdef INT64
     mpz_clear (mpz_int64_min);
-    push_int64 = bootstrap_push_int64;
-    int64_from_bignum = NULL;
+    hook_in_int64_funcs (NULL, NULL);
 #endif
   }
 #endif
@@ -1886,8 +1885,7 @@ PIKE_MODULE_INIT
     mpz_init (mpz_int64_min);
     mpz_setbit (mpz_int64_min, INT64_BITS);
     mpz_neg (mpz_int64_min, mpz_int64_min);
-    push_int64 = gmp_push_int64;
-    int64_from_bignum = gmp_int64_from_bignum;
+    hook_in_int64_funcs (gmp_push_int64, gmp_int64_from_bignum);
 #endif
 
 #if 0