diff --git a/includes/pager.inc b/includes/pager.inc
index c060d0e..050b5d1 100644
--- a/includes/pager.inc
+++ b/includes/pager.inc
@@ -15,13 +15,6 @@
 class PagerDefault extends SelectQueryExtender {
 
   /**
-   * The highest element we've autogenerated so far.
-   *
-   * @var int
-   */
-  static $maxElement = 0;
-
-  /**
    * The number of elements per page to allow.
    *
    * @var int
@@ -81,15 +74,17 @@ class PagerDefault extends SelectQueryExtender {
 
   /**
    * Ensure that there is an element associated with this query.
-   * If an element was not specified previously, then the value of the
-   * $maxElement counter is taken, after which the counter is incremented.
+   * If an element was not specified previously, then the value of the global
+   * $pager_page_array counter is taken, after which the counter is incremented.
    *
    * After running this method, access $this->element to get the element for this
    * query.
    */
   protected function ensureElement() {
     if (!isset($this->element)) {
-      $this->element = self::$maxElement++;
+      global $pager_page_array;
+      // Get the highest pager key and increment it.
+      $this->element = max(array_keys($pager_page_array)) + 1;
     }
   }
 
