diff --git a/Library/Homebrew/cleanup.rb b/Library/Homebrew/cleanup.rb
index 96689be11ba950e38df15dd4e418a3969af49894..41c4bbf34e0d1aa61609cabbae86cf45f1029f71 100644
--- a/Library/Homebrew/cleanup.rb
+++ b/Library/Homebrew/cleanup.rb
@@ -121,11 +121,12 @@ module Homebrew
         map { |p| HOMEBREW_PREFIX/p }.each { |p| paths << p if p.exist? }
       workers = (0...Hardware::CPU.cores).map do
         Thread.new do
-          begin
-            while p = paths.pop(true)
-              quiet_system "find", p, "-name", ".DS_Store", "-delete"
+          Kernel.loop do
+            begin
+              quiet_system "find", paths.deq(true), "-name", ".DS_Store", "-delete"
+            rescue ThreadError
+              break # if queue is empty
             end
-          rescue ThreadError # ignore empty queue error
           end
         end
       end
diff --git a/Library/Homebrew/readall.rb b/Library/Homebrew/readall.rb
index 4d09226f5e3fac44b3307873ab9a0a5d5ed97a36..61222e0154f6c3bea0f0a8cc03406988452bc198 100644
--- a/Library/Homebrew/readall.rb
+++ b/Library/Homebrew/readall.rb
@@ -11,12 +11,13 @@ module Readall
       failed = false
       workers = (0...Hardware::CPU.cores).map do
         Thread.new do
-          begin
-            while rb = ruby_files_queue.pop(true)
+          Kernel.loop do
+            begin
               # As a side effect, print syntax errors/warnings to `$stderr`.
-              failed = true if syntax_errors_or_warnings?(rb)
+              failed = true if syntax_errors_or_warnings?(ruby_files_queue.deq(true))
+            rescue ThreadError
+              break
             end
-          rescue ThreadError # ignore empty queue error
           end
         end
       end