Index: GoogleMini.php
===================================================================
--- GoogleMini.php	(revision 41675)
+++ GoogleMini.php	(revision 41676)
@@ -160,7 +160,7 @@
    *
    * @param string $keys
    */
-  public function setKeywords($keys) {		
+  public function setKeywords($keys) {
     if ($this->_queryParts['q']) {
       $this->_queryParts['q'] .= "%20". urlencode($keys);
     } else {
@@ -242,8 +242,8 @@
             // The 'OROR' case is used on the Related Information pages, where you want
             // to search documents with one of multiple terms in multiple vocabularies.
             // You have to join the different types with a | otherwise the date sorting gets messed up.
-            
-            
+
+
             /***
              * IMPORTANT!  The new Version of the Mini uses parenthesis.
              * This will not work for older versions pre August 2008 (I believe).
@@ -252,7 +252,7 @@
              * which will use the old ?
              *
              */
-            
+
             if ($mdf->type == 'OROR') {
               $metafilter .= '(' . join("|", $vals) . ")|";
             }
@@ -317,8 +317,8 @@
 
     $payload = simplexml_load_string($resultXML);
 
-    $totalResults = $payload->RES->M;    
-    
+    $totalResults = (int)$payload->RES->M;
+
     if ($totalResults == 0) {
       if (!$payload->GM) {
         throw new GoogleMiniResultException("No Results found", '1');
@@ -332,7 +332,7 @@
     $iterator = new $className($results);
     $iterator->payload = $payload;
     $iterator->time = $payload->TM;
-    $iterator->totalResults = $totalResults;
+    $iterator->totalResults = $totalResults > GOOGLE_MINI_MAX_RESULTS ? GOOGLE_MINI_MAX_RESULTS : $totalResults;
     return $iterator;
   }
 }
@@ -426,7 +426,7 @@
 }
 
 class GoogleMiniException extends Exception {
-  
+
   function __construct($message, $code = null) {
     parent::__construct($message, $code);
     $this->userMessage = GoogleMiniException::getUserMessage($code);
@@ -434,7 +434,7 @@
       $this->userMessage = $message;
     }
   }
-  
+
   function getErrorCodes() {
     static $error_codes;
     if (!$error_codes) {
@@ -447,10 +447,10 @@
     }
     return $error_codes;
   }
-  
-  
+
+
   function getUserMessage($code) {
-    $error_codes = $this->getErrorCodes();  
+    $error_codes = $this->getErrorCodes();
     return $error_codes[$code];
   }
 }
