diff --git a/src/dom/NodeIDMap.cpp b/src/dom/NodeIDMap.cpp
index 25863bcd3e1023a80c2871da81f22e1d5af4387b..c55650e9924b3c73cf41e27cde32c72fcae575f6 100644
--- a/src/dom/NodeIDMap.cpp
+++ b/src/dom/NodeIDMap.cpp
@@ -58,6 +58,7 @@
 #include "AttrImpl.hpp"
 #include "NodeIDMap.hpp"
 #include <util/XMLString.hpp>
+#include <stdio.h>
 
 static const int gPrimes[] = {997, 9973, 99991, 999983, 0 };  // To do - add a few more.
 
@@ -130,6 +131,8 @@ void NodeIDMap::add(AttrImpl *attr)
 			tableSlot == (AttrImpl *)-1)
 			break;
 		currentHash += initalHash;  // rehash
+        if (currentHash >= fSize)
+            currentHash = currentHash % fSize;
     }
 
     //
@@ -175,6 +178,8 @@ void NodeIDMap::remove(AttrImpl *attr)
         }
 
         currentHash += initalHash;  // rehash.
+        if (currentHash >= fSize)
+            currentHash = currentHash % fSize;
     }
 
 };
@@ -206,6 +211,8 @@ AttrImpl *NodeIDMap::find(const DOMString &id)
             return tableSlot;
 
         currentHash += initalHash;  // rehash
+        if (currentHash >= fSize)
+            currentHash = currentHash % fSize;
     }
     return 0;  // Never gets here, but keeps some compilers happy.
 };
@@ -224,6 +231,7 @@ void NodeIDMap::growTable()
     //
     //  Figure the new table size.
     //
+    fprintf(stderr, "growing...\n");
     fSizeIndex++;
     fSize = gPrimes[fSizeIndex];
     if (fSize == 0)
diff --git a/src/dom/NodeVector.cpp b/src/dom/NodeVector.cpp
index fcdd3b5b5fe5d65e6a240de30eb4cfaa89e80b99..0cba597291be76a14ef7415bd7158e804a2010d5 100644
--- a/src/dom/NodeVector.cpp
+++ b/src/dom/NodeVector.cpp
@@ -56,6 +56,10 @@
 
 /*
  * $Log$
+ * Revision 1.6  2000/05/22 22:38:12  andyh
+ * DOM: GetNodeById(), fixed bad problem with rehash operation that caused
+ * creashes.
+ *
  * Revision 1.5  2000/03/28 19:43:13  roddey
  * Fixes for signed/unsigned warnings. New work for two way transcoding
  * stuff.
@@ -140,6 +144,8 @@ void NodeVector::checkSpace() {
 
 	
 NodeImpl *NodeVector::elementAt(unsigned int index) {
+    if (index >= nextFreeSlot)
+        return 0;
 	return data[index];
 };