diff --git a/bbcode-filter.inc b/bbcode-filter.inc
index 3ccad95..a564fca 100644
--- a/bbcode-filter.inc
+++ b/bbcode-filter.inc
@@ -55,20 +55,32 @@ function _bbcode_filter_process(&$body, $format = -1) {
        $body = str_replace("***pRe_sTrInG$i***", $code_tag, $body);
   }
 
+  // Replace any improper quote tags with proper quote tags
+  $body = str_replace('[quote/]', '[/quote]', $body);
+  
   // Add closing tags to prevent users from disruping your site's HTML
   // (required for nestable tags only: [list] and [quote])
   preg_match_all('/\[quote/i', $body, $matches);
   $opentags = count($matches['0']);
   preg_match_all('/\[\/quote\]/i', $body, $matches);
   $unclosed = $opentags - count($matches['0']);
-  for ($i = 0; $i < $unclosed; $i++)
-     $body .= '[/quote]';
+  for ($i = 0; $i < $unclosed; $i++) {
+    $body .= '[/quote]';
+  }
+  // Also add opening tags, if needed
+  for ($i = $unclosed; $i < 0; $i++) {
+    $body = '[quote]' . $body;
+  }
   preg_match_all('/\[list/i', $body, $matches);
   $opentags = count($matches['0']);
   preg_match_all('/\[\/list\]/i', $body, $matches);
   $unclosed = $opentags - count($matches['0']);
-  for ($i = 0; $i < $unclosed; $i++) 
-     $body .= '[/list]';
+  for ($i = 0; $i < $unclosed; $i++) {
+    $body .= '[/list]';
+  }
+  for ($i = $unclosed; $i < 0; $i++) {
+    $body = '[list]' . $body;
+  }
 
   // begin processing for [size] 
   if (stristr($body, '[size=') !== FALSE) { // prevent useless processing
