diff -urp privatemsg/privatemsg.module privatemsg.new/privatemsg.module
--- privatemsg.module	2009-11-26 18:42:54.000000000 +0000
+++ privatemsg.module	2009-11-28 17:37:33.160050000 +0000
@@ -257,8 +257,8 @@ function privatemsg_view_access() {
  * @param $account
  *   User object for which the thread should be loaded, defaults to
  *   the current user.
- * @param $limit
- *   How many messages should be loaded. Note that counting starts from the end.
+ * @param $start
+ *   Message offset from the start of the thread.
  *
  * @return
  *   $thread object, with keys messages, participants, title and user. messages
@@ -270,7 +270,7 @@ function privatemsg_view_access() {
 
  * @ingroup api
  */
-function privatemsg_thread_load($thread_id, $account = NULL, $limit = NULL) {
+function privatemsg_thread_load($thread_id, $account = NULL, $start = NULL) {
   static $threads = array();
   if ((int)$thread_id > 0) {
     $thread = array('thread_id' => $thread_id);
@@ -297,42 +297,53 @@ function privatemsg_thread_load($thread_
         $thread['read_all'] = TRUE;
       }
 
-      // If limit is NULL, select based on get params.
-      if (is_null($limit)) {
-        if (isset($_GET['start'])) {
-          $limit = $_GET['start'];
-        }
-        else {
-          $limit = variable_get('privatemsg_view_use_max_as_default', FALSE) ? variable_get('privatemsg_view_default_amount', 10) : variable_get('privatemsg_view_max_amount', 20);
-        }
-      }
-      $thread['limit'] = $limit;
-
       // Load messages returned by the messages query with privatemsg_message_load_multiple().
       $query = _privatemsg_assemble_query('messages', array($thread_id), $thread['read_all'] ? NULL : $account);
       $thread['message_count'] = $thread['to'] = db_result(db_query($query['count']));
       $thread['from'] = 1;
       // Check if we need to limit the messages.
       $max_amount = variable_get('privatemsg_view_max_amount', 20);
-      if ($limit != PRIVATEMSG_UNLIMITED) {
+
+      // If there is no startvalue, select based on get params.
+      if (is_null($start)) {
+        if (isset($_GET['start'])) {
+          $start = $_GET['start'];
+        }
+        else {
+          $start = $thread['message_count'] - (variable_get('privatemsg_view_use_max_as_default', FALSE) ? variable_get('privatemsg_view_default_amount', 10) : variable_get('privatemsg_view_max_amount', 20));
+        }
+      }
+     
+      if ($start >= $thread['message_count']) {
+        $start = $thread['message_count'] - (variable_get('privatemsg_view_use_max_as_default', FALSE) ? variable_get('privatemsg_view_default_amount', 10) : variable_get('privatemsg_view_max_amount', 20));
+      }
+      if ($start < 0) {
+        $start = 0;
+      }
+      $thread['start'] = $start;
+
+      if ($start != PRIVATEMSG_UNLIMITED) {
         if ($max_amount == PRIVATEMSG_UNLIMITED) {
           $max_amount = $thread['older_start'] = $thread['message_count'];
         }
-        if ($thread['message_count'] > $limit) {
-          $thread['from'] = $thread['message_count'] - $limit + 1;
-          if ($thread['from'] + $max_amount - 1 < $thread['message_count']) {
-            $thread['to'] = $thread['from'] + $max_amount - 1;
-            $thread['newer_start'] = $limit - $max_amount;
+        if ($thread['message_count'] > $start) {
+          $thread['from'] = $start;
+          if ($thread['from'] + $max_amount < $thread['message_count']) {
+            $thread['to'] = $thread['from'] + $max_amount;
+            $thread['newer_start'] = $start + $max_amount;
           }
           if (empty($thread['older_start'])) {
-            $thread['older_start'] = $limit + $max_amount;
+            $thread['older_start'] = $start - $max_amount;
+            if ($thread['older_start'] < 0) {
+              $thread['older_start'] = 0;
+            }
           }
         }
-        elseif ($limit > $thread['message_count'] && ($thread['from'] + $max_amount - 1 < $thread['message_count'])) {
-          $thread['newer_start'] = $limit - $max_amount;
-          $thread['to'] = $max_amount = $thread['message_count'] - $limit + $max_amount;
+        elseif ($start > $thread['message_count'] && ($thread['from'] + $max_amount < $thread['message_count'])) {
+          $thread['older_start'] = $start - $max_amount;
+          $thread['to'] = $max_amount = $thread['message_count'] - $start + $max_amount;
         }
-        $conversation = db_query_range($query['query'], $thread['from'] - 1, $max_amount);
+        $conversation = db_query_range($query['query'], $thread['from'], $max_amount);
         }
       else {
         $conversation = db_query($query['query']);
@@ -739,7 +750,7 @@ function privatemsg_view($thread) {
   }
   $substitutions = array('@from' => $thread['from'], '@to' => $thread['to'], '@total' => $thread['message_count'], '!previous_link' => $older, '!newer_link' => $newer);
   $title = t('!previous_link Displaying messages @from - @to of @total !newer_link', $substitutions);
-  $content['display_all'] = array(
+  $content['display_pager'] = array(
     '#value'  => trim($title),
     '#prefix' => '<div class="privatemsg-view-pager">',
     '#suffix' => '</div>',
@@ -747,7 +758,7 @@ function privatemsg_view($thread) {
   );
 
   // Display a copy at the end.
-  $content['display_all_bottom'] = $content['display_all'];
+  $content['display_all_bottom'] = $content['display_pager'];
   $content['display_all_bottom']['#weight'] = 3;
 
   // Render the participants.
