diff --git a/lib/modules/Thread.pmod b/lib/modules/Thread.pmod
index a337ad18ce802a35bdd4af4f3b9bc17476a69eca..bd22fb0c600cb4dad917beb85bee33eddc8efd73 100644
--- a/lib/modules/Thread.pmod
+++ b/lib/modules/Thread.pmod
@@ -16,7 +16,8 @@ class Fifo {
       mixed tmp;
       object key=lock::lock();
       while(!num) r_cond::wait(key);
-      tmp=buffer[ptr++];
+      tmp=buffer[ptr];
+      buffer[ptr++] = 0;	// Throw away any references.
       ptr%=sizeof(buffer);
       num--;
       w_cond::signal();
@@ -51,7 +52,8 @@ class Queue {
       mixed tmp;
       object key=lock::lock();
       while(!size()) r_cond::wait(key);
-      tmp=buffer[r_ptr++];
+      tmp=buffer[r_ptr];
+      buffer[r_ptr++] = 0;	// Throw away any references.
       key=0;
       return tmp;
     }