diff --git a/quote.module b/quote.module
index 9e0114c..ea6f4f1 100644
--- a/quote.module
+++ b/quote.module
@@ -267,40 +267,35 @@
  */
 function _quote_filter_process($text) {
   if (stristr($text, '[quote')) {
-    // Single regexp with callback allowing for theme calls and quote
-    // nesting/recursion with regexp code from
-    // http://de.php.net/manual/en/function.preg-replace-callback.php#85836
-    $text = preg_replace_callback('#\[(quote.*?)]((?>\[(?!/?quote[^[]*?])|[^[]|(?R))*)\[/quote]#is', '_quote_filter_process_callback', $text);
+    $text_original = $text;
+    $pattern = '#\[(quote.*?)]((?>\[(?!/?quote[^[]*?])|[^[]|(?R))*)\[/quote]#is';
+
+    $index = 0;
+    $quotes = array();
+    while (preg_match_all($pattern, $text, $matches, PREG_SET_ORDER)) {
+      $quotes[++$index] = array_shift($matches);
+      $text = $quotes[$index][2];
+    }
+
+    $quote = end($quotes);
+    $key = key($quotes);
+    while ($quote) {
+      $quote_original = $quote[0];
+      $quote_author = trim(drupal_substr($quote[1], 6));
+      $quote_content = $quote[2];
+
+      $quote_output = theme('quote', array('quote_content' => $quote_content, 'quote_author' => $quote_author, 'nest' => $key));
+      if ($quote = prev($quotes)) {
+        $key = key($quotes);
+        $quote[2] = str_replace($quote_original, $quote_output, $quote[2]);
+      }
+      else {
+        $text = str_replace($quote_original, $quote_output, $text_original);
+      }
+    }
   }
 
   return $text;
-}
-
-/**
- * Generate and return the quote theming for a quote occurence found by
- * _quote_filter_process().
- *
- * @param $matches
- *   The RegExp matches (for author and quote) found in _quote_filter_process().
- *
- * @return $output_quote
- *   Themed quote.
- */
-function _quote_filter_process_callback($matches) {
-  static $index = 0;
-
-  $nest = ++$index;
-
-  if (!stristr($matches[2], '[quote')) {
-    $index = 0;
-  }
-
-  $quote_author = trim(drupal_substr($matches[1], 6));
-  $quote_content = _quote_filter_process($matches[2]);
-
-  $quote_output = theme('quote', array('quote_content' => $quote_content, 'quote_author' => $quote_author, 'nest' => $nest));
-
-  return $quote_output;
 }
 
 /**