--- comment_mover.module.orig	2006-08-31 23:42:41.000000000 -0400
+++ comment_mover.module	2006-12-06 23:19:28.000000000 -0500
@@ -374,25 +374,11 @@ function comment_mover_build_thread($edi
     // Strip the "/" from the end of the thread.
     $max = rtrim($max, '/');
 
-    // Next, we increase this value by one.  Note that we can't
-    // use 1, 2, 3, ... 9, 10, 11 because we order by string and
-    // 10 would be right after 1.  We use 1, 2, 3, ..., 9, 91,
-    // 92, 93, ... instead.  Ugly but fast.
-    $decimals = (string) substr($max, 0, strlen($max) - 1);
-    $units = substr($max, -1, 1);
-    if ($units) {
-      $units++;
+    if(!$max) {
+       $thread = int2vancode(0) . '/';
+    } else {
+       $thread = int2vancode(vancode2int($max)+1) . '/';
     }
-    else {
-      $units = 1;
-    }
-
-    if ($units == 10) {
-      $units = '90';
-    }
-
-    // Finally, build the thread field for this new comment.
-    $thread = $decimals . $units .'/';
   }
   else {
     // This is comment with a parent comment: we increase
@@ -409,7 +395,7 @@ function comment_mover_build_thread($edi
 
     if ($max == '') {
       // First child of this parent.
-      $thread = $parent->thread .'.01/';
+      $thread = $parent->thread .'.00/';
     }
     else {
       // Strip the "/" at the end of the thread.
@@ -420,19 +406,7 @@ function comment_mover_build_thread($edi
       $parent_depth = count(explode('.', $parent->thread));
       $last = $parts[$parent_depth];
 
-      // Next, we increase this value by one.  Note that we can't
-      // use 1, 2, 3, ... 9, 10, 11 because we order by string and
-      // 10 would be right after 1.  We use 1, 2, 3, ..., 9, 91,
-      // 92, 93, ... instead.  Ugly but fast.
-      $decimals = (string)substr($last, 0, strlen($last) - 1);
-      $units = substr($last, -1, 1);
-      $units++;
-      if ($units == 10) {
-        $units = '90';
-      }
-
-      // Finally, build the thread field for this new comment.
-      $thread = $parent->thread .'.'. $decimals . $units .'/';
+      $thread = $parent->thread .'.'. int2vancode(vancode2int($last) + 1) .'/';
     }
   }
 
@@ -445,14 +419,14 @@ function comment_mover_build_thread($edi
  */
 function comment_mover_get_thread($parent) {
   if (isset($parent['cid'])) {
-    $query = "SELECT c.cid as cid, c.pid, c.nid, c.subject, c.comment, c.format, c.timestamp, c.name , c.mail, c.homepage, u.uid, u.name AS registered_name, u.picture, u.data, c.score, c.users, c.thread FROM {comments} c INNER JOIN {users} u ON c.uid = u.uid WHERE c.nid = %d AND SUBSTRING(c.thread, 1, LENGTH('%s')) = '%s' AND c.cid != %d AND c.status = 0 GROUP BY c.cid, c.pid, c.nid, c.subject, c.comment, c.format, c.timestamp, c.name, c.mail, u.picture, c.homepage, u.uid, u.name, u.picture, u.data, c.score, c.users, c.thread ORDER BY c.thread DESC";
+    $query = "SELECT c.cid as cid, c.pid, c.nid, c.subject, c.comment, c.format, c.timestamp, c.name , c.mail, c.homepage, u.uid, u.name AS registered_name, u.picture, u.data, c.score, c.users, c.thread FROM {comments} c INNER JOIN {users} u ON c.uid = u.uid WHERE c.nid = %d AND SUBSTRING(c.thread, 1, LENGTH('%s')) = '%s' AND c.cid != %d AND c.status = 0 GROUP BY c.cid, c.pid, c.nid, c.subject, c.comment, c.format, c.timestamp, c.name, c.mail, u.picture, c.homepage, u.uid, u.name, u.picture, u.data, c.score, c.users, c.thread ORDER BY c.thread";
 
     $depth = substr_count($parent['thread'], '.');
     $thread = substr($parent['thread'], 0, strlen($parent['thread']) - 1);
     $result = db_query($query, $parent['nid'], $thread, $thread, $parent['cid']);
   }
   else {
-    $query = "SELECT c.cid as cid, c.pid, c.nid, c.subject, c.comment, c.format, c.timestamp, c.name , c.mail, c.homepage, u.uid, u.name AS registered_name, u.picture, u.data, c.score, c.users, c.thread FROM {comments} c INNER JOIN {users} u ON c.uid = u.uid WHERE c.nid = %d GROUP BY c.cid, c.pid, c.nid, c.subject, c.comment, c.format, c.timestamp, c.name, c.mail, u.picture, c.homepage, u.uid, u.name, u.picture, u.data, c.score, c.users, c.thread ORDER BY c.thread DESC";
+    $query = "SELECT c.cid as cid, c.pid, c.nid, c.subject, c.comment, c.format, c.timestamp, c.name , c.mail, c.homepage, u.uid, u.name AS registered_name, u.picture, u.data, c.score, c.users, c.thread FROM {comments} c INNER JOIN {users} u ON c.uid = u.uid WHERE c.nid = %d GROUP BY c.cid, c.pid, c.nid, c.subject, c.comment, c.format, c.timestamp, c.name, c.mail, u.picture, c.homepage, u.uid, u.name, u.picture, u.data, c.score, c.users, c.thread ORDER BY c.thread";
     $result = db_query($query, $parent['nid']);
     $depth = - 1;
   }
