diff --git a/CHANGELOG b/CHANGELOG
index fe0f4328b168cf7b24f02f08c68616bf4bb7d405..62abda7f2770cfd1cc3ef78931e8191cda64e08b 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,13 +1,24 @@
 drupal x.xx, xx/xx/xxxx
 -----------------------
-- major overhaul of the underlying design:
+- major overhaul of the entire underlying design:
     * everything is based on nodes
-    * introduced links / drupal tags
-- refactored submission / moderation queue
-- added a "wiki module"
+    * introduced links/drupal tags
+- rewrote submission/moderation queue:
+    * renamed submission.module to moderation.module
+    * updated submission forms
+- added a "book module":
+    * merged documentation and FAQ module into a book module
 - various updates:
     * added preview functionality when submitting new content (such as a story) from the administration pages.
     * made the administration section only show those links a user has access to.
+    * improved account module
+    * improved comment module
+    * improved story module:
+        + stories can now be permanently deleted
+    * improved themes:
+        + W3C validation on a best effort basis
+        + added goofy theme
+- revised documentation
 
 drupal 2.00, 15/03/2001
 -----------------------
@@ -45,7 +56,7 @@ drupal 2.00, 15/03/2001
     * improved database abstraction layer
     * improved themes:
         + W3C validation on a best effort basis
-        + added example theme for theme designers
+        + added example theme
     * added CREDITS file
     * added directory "misc"
     * added new scripts to directory "scripts"
diff --git a/account.php b/account.php
index 1fd51a8d78108f72fb9a7e8d0fecbcf8c0dcdaf5..7b698c9f0c4edd015329c01b1d6d386c5aaad8ec 100644
--- a/account.php
+++ b/account.php
@@ -254,7 +254,7 @@ function module($name, $module, $username) {
     $block1 .= "</TABLE>\n";
 
 /*
-    $result = db_query("SELECT c.cid, c.pid, c.lid, c.subject, c.timestamp, n.title AS node FROM comments c LEFT JOIN users u ON u.id = c.author LEFT JOIN nodes ON n.id = c.lid WHERE u.userid = '$uname' AND n.status = '$status[posted]' AND s.timestamp > ". (time() - 1209600) ." ORDER BY cid DESC LIMIT 10");
+    $result = db_query("SELECT c.cid, c.pid, c.lid, c.subject, c.timestamp, n.title AS node FROM comments c LEFT JOIN users u ON u.id = c.author LEFT JOIN node ON n.id = c.lid WHERE u.userid = '$uname' AND n.status = '$status[posted]' AND s.timestamp > ". (time() - 1209600) ." ORDER BY cid DESC LIMIT 10");
     while ($comment = db_fetch_object($result)) {
       $block2 .= "<TABLE BORDER=\"0\" CELLPADDING=\"1\" CELLSPACING=\"1\">\n";
       $block2 .= " <TR><TD ALIGN=\"right\"><B>". t("Comment") .":</B></TD><TD><A HREF=\"node.php?id=$comment->lid&cid=$comment->cid&pid=$comment->pid#$comment->cid\">". check_output($comment->subject) ."</A></TD></TR>\n";
@@ -406,7 +406,7 @@ function account_password($min_length=6) {
 function account_track_comments() {
   global $theme, $user;
 
-  $sresult = db_query("SELECT n.nid, n.title, COUNT(n.nid) AS count FROM comments c LEFT JOIN nodes n ON c.lid = n.nid WHERE c.author = '$user->id' GROUP BY n.nid DESC LIMIT 5");
+  $sresult = db_query("SELECT n.nid, n.title, COUNT(n.nid) AS count FROM comments c LEFT JOIN node n ON c.lid = n.nid WHERE c.author = '$user->id' GROUP BY n.nid DESC LIMIT 5");
 
   while ($node = db_fetch_object($sresult)) {
     $output .= "<LI>". format_plural($node->count, "comment", "comments") ." ". t("attached to node") ." `<A HREF=\"node.php?id=$node->nid\">". check_output($node->title) ."</A>`:</LI>\n";
@@ -427,7 +427,7 @@ function account_track_comments() {
 function account_track_nodes() {
   global $status, $theme, $user;
 
-  $result = db_query("SELECT n.nid, n.type, n.title, n.timestamp, COUNT(c.cid) AS count FROM nodes n LEFT JOIN comments c ON c.lid = n.nid WHERE n.status = '$status[posted]' AND n.author = '$user->id' GROUP BY n.nid DESC LIMIT 25");
+  $result = db_query("SELECT n.nid, n.type, n.title, n.timestamp, COUNT(c.cid) AS count FROM node n LEFT JOIN comments c ON c.lid = n.nid WHERE n.status = '$status[posted]' AND n.author = '$user->id' GROUP BY n.nid DESC LIMIT 25");
 
   while ($node = db_fetch_object($result)) {
     $output .= "<TABLE BORDER=\"0\" CELLPADDING=\"1\" CELLSPACING=\"1\">\n";
@@ -448,7 +448,7 @@ function account_track_site() {
 
   $period = 259200; // 3 days
 
-  $sresult = db_query("SELECT n.title, n.nid, COUNT(c.lid) AS count FROM comments c LEFT JOIN nodes n ON c.lid = n.nid WHERE n.status = '$status[posted]' AND ". time() ." - n.timestamp < $period GROUP BY c.lid ORDER BY n.timestamp DESC LIMIT 10");
+  $sresult = db_query("SELECT n.title, n.nid, COUNT(c.lid) AS count FROM comments c LEFT JOIN node n ON c.lid = n.nid WHERE n.status = '$status[posted]' AND ". time() ." - n.timestamp < $period GROUP BY c.lid ORDER BY n.timestamp DESC LIMIT 10");
   while ($node = db_fetch_object($sresult)) {
     $output .= "<LI>". format_plural($node->count, "comment", "comments") ." ". t("attached to node") ." '<A HREF=\"node.php?id=$node->nid\">". check_output($node->title) ."</A>':</LI>";
 
diff --git a/cron.php b/cron.php
index 33114768b12563bc1b43b3780379a2993fd90ba7..d2d2ece5b82af831c405e4c2a82635be309e9c51 100644
--- a/cron.php
+++ b/cron.php
@@ -10,10 +10,7 @@ function cron_run() {
   $result = db_query("SELECT * FROM crons WHERE $time - timestamp > scheduled");
 
   while ($task = db_fetch_object($result)) {
-    if ($repository[$task->module]["cron"]) {
-      watchdog("message", "cron: executed '". $task->module ."_cron()'");
-      $repository[$task->module]["cron"]();
-    }
+    if ($repository[$task->module]["cron"]) $repository[$task->module]["cron"]();
   }
 
   db_query("UPDATE crons SET timestamp = $time WHERE $time - timestamp > scheduled");
diff --git a/includes/ban.inc b/includes/ban.inc
index 64d2cc434f8f96232bcae96746ea1582a75a5dd6..98f39be6d6cd1b77007e84bda37970c0d836a5ef 100644
--- a/includes/ban.inc
+++ b/includes/ban.inc
@@ -18,7 +18,8 @@ function ban_match($mask, $category) {
   return db_fetch_object($result);
 }
 
-function ban_add($mask, $category, $reason, $message = "") {
+// TODO --> $message by reference
+function ban_add($mask, $category, $reason, $message = 0) {
   global $index2type;
 
   if (empty($mask)) {
diff --git a/includes/comment.inc b/includes/comment.inc
index c775be98facb128821b9a1c3732f618cdeaaa722..57b87583b2c7badf6079a58bf91f487e7b2a0e21 100644
--- a/includes/comment.inc
+++ b/includes/comment.inc
@@ -128,14 +128,14 @@ function comment_post($pid, $id, $subject, $comment) {
   $duplicate = db_result(db_query("SELECT COUNT(cid) FROM comments WHERE pid = '$pid' AND lid = '$id' AND subject = '$subject' AND comment = '$comment'"), 0);
 
   if ($duplicate != 0) {
-    watchdog("error", "comment: attempt to insert duplicate comment");
+    watchdog("warning", "comment: duplicate '$subject'");
   }
   else {
     // Validate subject:
     $subject = ($subject) ? $subject : substr($comment, 0, 29);
 
     // Add watchdog entry:
-    watchdog("comment", "comment: added comment with subject '$subject'");
+    watchdog("comment", "comment: added '$subject'");
 
     // Add comment to database:
     db_query("INSERT INTO comments (lid, pid, author, subject, comment, hostname, timestamp, score) VALUES ('$id', '$pid', '$user->id', '$subject', '$comment', '". getenv("REMOTE_ADDR") ."', '". time() ."', '". ($user->userid ? 1 : 0) ."')");
diff --git a/includes/function.inc b/includes/function.inc
index eb1a08b3c6b0edfb4ebb76636214d4aa820489a5..809fd4ed9ad7cd48ab1d8a4b0a714441bc8e7049 100644
--- a/includes/function.inc
+++ b/includes/function.inc
@@ -48,7 +48,7 @@ function format_interval($timestamp) {
     $timestamp = $timestamp % 3600;
   }
   if ($timestamp >= 60) {
-    $output .= " ". floor($timestamp / 60) ."min";
+    $output .= " ". floor($timestamp / 60) ." min";
     $timestamp = $timestamp % 60;
   }
   if ($timestamp > 0) {
diff --git a/includes/node.inc b/includes/node.inc
index d6c7a9744c578785038e44455842fb46412ff21b..b58609d042effcbd49fded30ae575397ef8dbd8c 100644
--- a/includes/node.inc
+++ b/includes/node.inc
@@ -3,9 +3,9 @@
 $status = array(dumped => 0, expired => 1, queued => 2, posted => 3, scheduled => 4);
 
 function _node_get($field, $value) {
-  $result = db_query("SELECT lid, type FROM nodes WHERE $field = '$value'");
+  $result = db_query("SELECT lid, type FROM node WHERE $field = '$value'");
   if ($node = db_fetch_object($result)) {
-    return db_query("SELECT n.*, l.*, u.userid FROM nodes n LEFT JOIN $node->type l ON n.lid = l.id AND l.node = n.nid LEFT JOIN users u ON n.author = u.id WHERE n.$field = '$value' ORDER BY n.timestamp DESC");
+    return db_query("SELECT n.*, l.*, u.userid FROM node n LEFT JOIN $node->type l ON n.lid = l.lid AND n.nid = l.nid LEFT JOIN users u ON n.author = u.id WHERE n.$field = '$value' ORDER BY n.timestamp DESC");
   }
 }
 
@@ -21,8 +21,9 @@ function node_del($field, $value) {
   global $status;
   if ($node = node_get_object($field, $value)) {
     if ($node->status == $status[dumped]) {
-      db_query("DELETE FROM nodes WHERE nid = '$node->nid'");
-      db_query("DELETE FROM $node->type WHERE node = '$node->nid'");
+      db_query("DELETE FROM node WHERE nid = '$node->nid'");
+      db_query("DELETE FROM $node->type WHERE lid = '$node->lid' AND nid = '$node->nid'");
+      db_query("DELETE FROM comments WHERE lid = '$node->nid'");
       watchdog("message", "node: deleted '$node->title'");
       return $node;
     }
@@ -50,8 +51,8 @@ function node_save($node) {
     $u1 = implode(", ", $u1);
     $u2 = implode(", ", $u2);
 
-    db_query("UPDATE nodes SET $u1 WHERE nid = '$node[nid]'");
-    db_query("UPDATE $node[type] SET $u2 WHERE node = '$node[nid]'");
+    db_query("UPDATE node SET $u1 WHERE nid = '$node[nid]'");
+    db_query("UPDATE $node[type] SET $u2 WHERE nid = '$node[nid]'");
 
     watchdog("message", "node: modified '$node[title]'");
   }
@@ -59,7 +60,7 @@ function node_save($node) {
     $duplicate = node_get_object("title", $node[title]);
 
     if ($duplicate && (time() - $duplicate->timestamp < 300)) {
-      watchdog("warning", "node: duplicate node '$node[title]'");
+      watchdog("warning", "node: duplicate '$node[title]'");
     }
     else {
       // setup default values:
@@ -87,14 +88,14 @@ function node_save($node) {
       $f2 = implode(", ", $f2);
       $v2 = implode(", ", $v2);
 
-      db_query("INSERT INTO nodes ($f1) VALUES ($v1)");
+      db_query("INSERT INTO node ($f1) VALUES ($v1)");
       if ($nid = db_insert_id()) {
-        $lid = db_query("INSERT INTO $node[type] ($f2, node) VALUES ($v2, $nid)");
+        $lid = db_query("INSERT INTO $node[type] ($f2, nid) VALUES ($v2, $nid)");
         if ($lid = db_insert_id()) {
-          db_query("UPDATE nodes SET lid = '$lid' WHERE nid = '$nid'");
+          db_query("UPDATE node SET lid = '$lid' WHERE nid = '$nid'");
         }
         else {
-          db_query("DELETE FROM nodes WHERE nid = '$nid'");
+          db_query("DELETE FROM node WHERE nid = '$nid'");
         }
       }
 
@@ -103,7 +104,7 @@ function node_save($node) {
   }
 
   if (($node[pid]) && ($node[status] == $status[posted])) {
-    db_query("UPDATE nodes SET status = '$status[expired]' WHERE nid = '$node[pid]'");
+    db_query("UPDATE node SET status = '$status[expired]' WHERE nid = '$node[pid]'");
   }
 }
 
diff --git a/includes/search.inc b/includes/search.inc
index 47eefecd92d14f4c5f454bcd36e654a3dc93fb4a..cf47ebda8d6d56924391fb00ff525b5479f4749b 100644
--- a/includes/search.inc
+++ b/includes/search.inc
@@ -11,7 +11,7 @@ function search_form($keys) {
 
 function search_data($keys, $type) {
   if ($keys && $type) {
-    $result = module_execute($type, "find", $keys);
+    $result = module_execute($type, "find", check_input($keys));
     foreach ($result as $entry) {
       $output .= "<P>\n";
       $output .= " <B><U><A HREF=\"$entry[link]\">$entry[title]</A></U></B><BR>";
diff --git a/includes/theme.inc b/includes/theme.inc
index 3ac8ded062979bd2c8b530b44888a8f517cbfa6a..5ba2daa1042490568a7a7d0388a2dfa604566645 100644
--- a/includes/theme.inc
+++ b/includes/theme.inc
@@ -18,7 +18,7 @@ function theme_link($separator = " | ") {
                  "<A HREF=\"submit.php\">". t("submit") ."</A>",
                  "<A HREF=\"module.php?mod=diary\">". t("diary") ."</A>",
                  "<A HREF=\"account.php\">". t("account") ."</A>",
-                 "<A HREF=\"module.php?mod=book\">". t("help") ."</A>");
+                 "<A HREF=\"module.php?mod=book\">". t("handbook") ."</A>");
   return implode($separator, $links);
 }
 
@@ -80,7 +80,7 @@ function theme_blocks($region, $theme) {
   switch (strrchr($PHP_SELF, "/")) {
     case "/node.php":
       if ($region != "left") {
-        if ($user->id) $node = db_fetch_object(db_query("SELECT * FROM nodes WHERE nid = '$id'"));
+        if ($user->id) $node = db_fetch_object(db_query("SELECT * FROM node WHERE nid = '$id'"));
         if ($node->status == $status[queued]) theme_moderation_results($theme, $node);
         // else theme_new_headlines($theme);
       }
@@ -118,7 +118,7 @@ function theme_moderation_results($theme, $node) {
 // depricated -> new block strategy
 //
 function theme_new_headlines($theme, $num = 10) {
-  $result = db_query("SELECT nid, title FROM nodes WHERE status = 2 AND type = 'story' ORDER BY nid DESC LIMIT $num");
+  $result = db_query("SELECT nid, title FROM node WHERE status = 2 AND type = 'story' ORDER BY nid DESC LIMIT $num");
   while ($node = db_fetch_object($result)) $content .= "<LI><A HREF=\"node.php?id=$node->nid\">". check_output($node->title) ."</A></LI>\n";
   $theme->box(t("Latest headlines"), $content);
 }
diff --git a/index.php b/index.php
index bb928266fa1ec38906cc79ff75d750b0fe229e05..1e44332834f615d13807216b72537a90d31869bc 100644
--- a/index.php
+++ b/index.php
@@ -7,7 +7,7 @@
 $date = ($date > 0) ? $date : time();
 
 // Perform query:
-$result = db_query("SELECT n.*, s.*, u.userid, COUNT(c.lid) AS comments FROM nodes n LEFT JOIN story s ON n.nid = s.node LEFT JOIN comments c ON n.nid = c.lid LEFT JOIN users u ON n.author = u.id WHERE n.status = '$status[posted]' AND n.type = 'story' ". ($section ? "AND s.section = '$section' " : "") ."AND n.timestamp <= $date GROUP BY n.nid ORDER BY n.timestamp DESC LIMIT $number");
+$result = db_query("SELECT n.*, s.*, u.userid, COUNT(c.lid) AS comments FROM node n LEFT JOIN story s ON n.nid = s.nid LEFT JOIN comments c ON n.nid = c.lid LEFT JOIN users u ON n.author = u.id WHERE n.status = '$status[posted]' AND n.type = 'story' ". ($section ? "AND s.section = '$section' " : "") ."AND n.timestamp <= $date GROUP BY n.nid ORDER BY n.timestamp DESC LIMIT $number");
 
 // Display nodes:
 $theme->header();
diff --git a/modules/account.module b/modules/account.module
index 178b313013435faeb1afe31d86c0eb240b989d75..23699314015fc3310ce25b23c6c0d692240a24fd 100644
--- a/modules/account.module
+++ b/modules/account.module
@@ -59,7 +59,7 @@ function account_blocks($id) {
 }
 
 function account_nodes($id) {
-  $result = db_query("SELECT * FROM nodes WHERE author = $id ORDER BY timestamp DESC");
+  $result = db_query("SELECT * FROM node WHERE author = $id ORDER BY timestamp DESC");
   while ($node = db_fetch_object($result)) {
     $output .= "<LI><A HREF=\"node.php?id=$node->nid\">$node->title</A> ($node->type)</LI>\n";
   }
diff --git a/modules/backend.class b/modules/backend.class
index 9e505f70e513413f2d797aa6b9ebd9606caab5fa..b31372fb5ce552193d6f98deafa8eda2771a3702 100644
--- a/modules/backend.class
+++ b/modules/backend.class
@@ -53,7 +53,7 @@ class backend {
       $url = parse_url($this->file);
 
       // Retrieve data from website:
-      $fp = fsockopen($url[host], ($url[port] ? $url[port] : 80), &$errno, &$errstr, $timout);
+      $fp = fsockopen($url[host], ($url[port] ? $url[port] : 80), $errno, $errstr, $timout);
 
       if ($fp) {
         // Request data via URL:
diff --git a/modules/ban.module b/modules/ban.module
index 091cdd18c44b5fba3d41e892489d5dbe5b2b5cb4..3d1d8a64f2a280b46ef63610a84971c29d9d5fd8 100644
--- a/modules/ban.module
+++ b/modules/ban.module
@@ -29,7 +29,7 @@ function ban_help() {
 }
 
 function ban_admin_new($mask, $category, $reason) {
-  ban_add($mask, $category, $reason, &$message);
+  ban_add($mask, $category, $reason, $message);
   $output .= "$message\n";
   print $output;
 }
diff --git a/modules/book.module b/modules/book.module
index 4be40e6703b555c50499f47ba9dbd8ea79e5bedd..40baa52465710b05cb50a50f034854e4d552fe89 100644
--- a/modules/book.module
+++ b/modules/book.module
@@ -19,8 +19,8 @@ function Book($nid, $userid, $title, $body, $parent, $weight, $timestamp) {
 
 function book_navigation($node) {
   if ($node->nid) {
-    $next = db_fetch_object(db_query("SELECT n.nid, n.title FROM nodes n LEFT JOIN book b ON n.nid = b.node WHERE b.parent = '$node->parent' AND b.weight > $node->weight ORDER BY b.weight ASC"));
-    $prev = db_fetch_object(db_query("SELECT n.nid, n.title FROM nodes n LEFT JOIN book b ON n.nid = b.node WHERE b.parent = '$node->parent' AND b.weight < $node->weight ORDER BY b.weight DESC"));
+    $next = db_fetch_object(db_query("SELECT n.nid, n.title FROM node n LEFT JOIN book b ON n.nid = b.nid AND n.lid = b.lid WHERE b.parent = '$node->parent' AND b.weight > $node->weight ORDER BY b.weight ASC"));
+    $prev = db_fetch_object(db_query("SELECT n.nid, n.title FROM node n LEFT JOIN book b ON n.nid = b.nid AND n.lid = b.lid WHERE b.parent = '$node->parent' AND b.weight < $node->weight ORDER BY b.weight DESC"));
   }
 
   $output .= "<HR>";
@@ -62,7 +62,7 @@ function book_view($node, $page = 1) {
 function book_find($keys) {
   global $status, $user;
   $find = array();
-  $result = db_query("SELECT n.*, u.userid FROM nodes n LEFT JOIN book b ON n.nid = b.node LEFT JOIN users u ON n.author = u.id WHERE n.type = 'book' AND n.status = '$status[posted]' AND (n.title LIKE '%". check_input($keys) ."%' OR b.body LIKE '%". check_input($keys) ."%') ORDER BY n.timestamp DESC LIMIT 20");
+  $result = db_query("SELECT n.*, u.userid FROM node n LEFT JOIN book b ON n.nid = b.nid AND n.lid = b.lid LEFT JOIN users u ON n.author = u.id WHERE n.type = 'book' AND n.status = '$status[posted]' AND (n.title LIKE '%". check_input($keys) ."%' OR b.body LIKE '%". check_input($keys) ."%') ORDER BY n.timestamp DESC LIMIT 20");
   while ($node = db_fetch_object($result)) {
     array_push($find, array("title" => check_output($node->title), "link" => (user_access($user, "book") ? "admin.php?mod=book&op=edit&id=$node->nid" : "node.php?id=$node->nid"), "user" => $node->userid, "date" => $node->timestamp));
   }
@@ -77,7 +77,7 @@ function book_search() {
 
 function book_toc($parent = 0, $offset = 0, $toc = array()) {
   global $status;
-  $result = db_query("SELECT n.*, b.* FROM nodes n LEFT JOIN book b ON n.nid = b.node WHERE n.type = 'book' AND n.status = '$status[posted]' AND b.parent = '$parent' ORDER BY b.weight");
+  $result = db_query("SELECT n.*, b.* FROM node n LEFT JOIN book b ON n.nid = b.nid AND n.lid = b.lid WHERE n.type = 'book' AND n.status = '$status[posted]' AND b.parent = '$parent' ORDER BY b.weight");
   while ($node = db_fetch_object($result)) {
     $toc[$node->nid] = ($offset ? $offset : "") ."". ++$number .". $node->title";
     $toc = book_toc($node->nid, ($offset ? "$offset." : "") ."$number.", $toc);
@@ -165,7 +165,7 @@ function book_delete($id) {
 function book_overview($parent = "", $offset = "") {
   global $PHP_SELF, $status;
 
-  $result = db_query("SELECT n.*, b.* FROM nodes n LEFT JOIN book b ON n.nid = b.node WHERE n.type = 'book' AND n.status = '$status[posted]' AND b.parent = '$parent' ORDER BY b.weight");
+  $result = db_query("SELECT n.*, b.* FROM node n LEFT JOIN book b ON n.nid = b.nid AND n.lid = b.lid WHERE n.type = 'book' AND n.status = '$status[posted]' AND b.parent = '$parent' ORDER BY b.weight");
 
   $output .= "<DL>";
   while ($node = db_fetch_object($result)) {
@@ -182,7 +182,7 @@ function book_overview($parent = "", $offset = "") {
 function book_history() {
   global $status;
 
-  $result = db_query("SELECT n.*, b.* FROM nodes n LEFT JOIN book b ON n.nid = b.node WHERE n.type = 'book' AND n.status != '$status[expired]' ORDER BY n.timestamp DESC");
+  $result = db_query("SELECT n.*, b.* FROM node n LEFT JOIN book b ON n.nid = b.nid AND n.lid = b.lid WHERE n.type = 'book' AND n.status != '$status[expired]' ORDER BY n.timestamp DESC");
 
   $output .= "<TABLE BORDER=\"1\" CELLPADDING=\"2\" CELLSPACING=\"2\">\n";
   $output .= " <TR><TH>node</TH><TH>status</TH><TH>date</TH><TH COLSPAN=\"3\">operations</TH></TR>\n";
diff --git a/modules/book/book.module b/modules/book/book.module
index 4be40e6703b555c50499f47ba9dbd8ea79e5bedd..40baa52465710b05cb50a50f034854e4d552fe89 100644
--- a/modules/book/book.module
+++ b/modules/book/book.module
@@ -19,8 +19,8 @@ function Book($nid, $userid, $title, $body, $parent, $weight, $timestamp) {
 
 function book_navigation($node) {
   if ($node->nid) {
-    $next = db_fetch_object(db_query("SELECT n.nid, n.title FROM nodes n LEFT JOIN book b ON n.nid = b.node WHERE b.parent = '$node->parent' AND b.weight > $node->weight ORDER BY b.weight ASC"));
-    $prev = db_fetch_object(db_query("SELECT n.nid, n.title FROM nodes n LEFT JOIN book b ON n.nid = b.node WHERE b.parent = '$node->parent' AND b.weight < $node->weight ORDER BY b.weight DESC"));
+    $next = db_fetch_object(db_query("SELECT n.nid, n.title FROM node n LEFT JOIN book b ON n.nid = b.nid AND n.lid = b.lid WHERE b.parent = '$node->parent' AND b.weight > $node->weight ORDER BY b.weight ASC"));
+    $prev = db_fetch_object(db_query("SELECT n.nid, n.title FROM node n LEFT JOIN book b ON n.nid = b.nid AND n.lid = b.lid WHERE b.parent = '$node->parent' AND b.weight < $node->weight ORDER BY b.weight DESC"));
   }
 
   $output .= "<HR>";
@@ -62,7 +62,7 @@ function book_view($node, $page = 1) {
 function book_find($keys) {
   global $status, $user;
   $find = array();
-  $result = db_query("SELECT n.*, u.userid FROM nodes n LEFT JOIN book b ON n.nid = b.node LEFT JOIN users u ON n.author = u.id WHERE n.type = 'book' AND n.status = '$status[posted]' AND (n.title LIKE '%". check_input($keys) ."%' OR b.body LIKE '%". check_input($keys) ."%') ORDER BY n.timestamp DESC LIMIT 20");
+  $result = db_query("SELECT n.*, u.userid FROM node n LEFT JOIN book b ON n.nid = b.nid AND n.lid = b.lid LEFT JOIN users u ON n.author = u.id WHERE n.type = 'book' AND n.status = '$status[posted]' AND (n.title LIKE '%". check_input($keys) ."%' OR b.body LIKE '%". check_input($keys) ."%') ORDER BY n.timestamp DESC LIMIT 20");
   while ($node = db_fetch_object($result)) {
     array_push($find, array("title" => check_output($node->title), "link" => (user_access($user, "book") ? "admin.php?mod=book&op=edit&id=$node->nid" : "node.php?id=$node->nid"), "user" => $node->userid, "date" => $node->timestamp));
   }
@@ -77,7 +77,7 @@ function book_search() {
 
 function book_toc($parent = 0, $offset = 0, $toc = array()) {
   global $status;
-  $result = db_query("SELECT n.*, b.* FROM nodes n LEFT JOIN book b ON n.nid = b.node WHERE n.type = 'book' AND n.status = '$status[posted]' AND b.parent = '$parent' ORDER BY b.weight");
+  $result = db_query("SELECT n.*, b.* FROM node n LEFT JOIN book b ON n.nid = b.nid AND n.lid = b.lid WHERE n.type = 'book' AND n.status = '$status[posted]' AND b.parent = '$parent' ORDER BY b.weight");
   while ($node = db_fetch_object($result)) {
     $toc[$node->nid] = ($offset ? $offset : "") ."". ++$number .". $node->title";
     $toc = book_toc($node->nid, ($offset ? "$offset." : "") ."$number.", $toc);
@@ -165,7 +165,7 @@ function book_delete($id) {
 function book_overview($parent = "", $offset = "") {
   global $PHP_SELF, $status;
 
-  $result = db_query("SELECT n.*, b.* FROM nodes n LEFT JOIN book b ON n.nid = b.node WHERE n.type = 'book' AND n.status = '$status[posted]' AND b.parent = '$parent' ORDER BY b.weight");
+  $result = db_query("SELECT n.*, b.* FROM node n LEFT JOIN book b ON n.nid = b.nid AND n.lid = b.lid WHERE n.type = 'book' AND n.status = '$status[posted]' AND b.parent = '$parent' ORDER BY b.weight");
 
   $output .= "<DL>";
   while ($node = db_fetch_object($result)) {
@@ -182,7 +182,7 @@ function book_overview($parent = "", $offset = "") {
 function book_history() {
   global $status;
 
-  $result = db_query("SELECT n.*, b.* FROM nodes n LEFT JOIN book b ON n.nid = b.node WHERE n.type = 'book' AND n.status != '$status[expired]' ORDER BY n.timestamp DESC");
+  $result = db_query("SELECT n.*, b.* FROM node n LEFT JOIN book b ON n.nid = b.nid AND n.lid = b.lid WHERE n.type = 'book' AND n.status != '$status[expired]' ORDER BY n.timestamp DESC");
 
   $output .= "<TABLE BORDER=\"1\" CELLPADDING=\"2\" CELLSPACING=\"2\">\n";
   $output .= " <TR><TH>node</TH><TH>status</TH><TH>date</TH><TH COLSPAN=\"3\">operations</TH></TR>\n";
diff --git a/modules/cron.module b/modules/cron.module
index d316b0b3996df083b0f8faf2ff291c9097879213..d34a2f291e421544cedffc2fbca1a39239880a20 100644
--- a/modules/cron.module
+++ b/modules/cron.module
@@ -33,10 +33,10 @@ function cron_display() {
   // Generate output:
   $output .= "<FORM ACTION=\"admin.php?mod=cron\" METHOD=\"post\">\n";
   $output .= "<TABLE BORDER=\"1\" CELLPADDING=\"2\" CELLSPACING=\"2\">\n";
-  $output .= " <TR><TH>module</TH><TH>period</TH><TH>last execution</TH><TH>operations</TH></TR>\n";
+  $output .= " <TR><TH>module</TH><TH>period</TH><TH>last run</TH><TH>next run</TH><TH>operations</TH></TR>\n";
   while ($cron = db_fetch_object($result)) {
     foreach ($intervals as $value) $period .= "<OPTION VALUE=\"$value\"". (($cron->scheduled == $value) ? " SELECTED" : "") .">every ". format_interval($value) ."</OPTION>\n";
-    $output .= " <TR><TD>". check_output($cron->module) ."</TD><TD><SELECT NAME=\"edit[$cron->module]\">$period</SELECT></TD><TD ALIGN=\"center\">". ($cron->timestamp ? format_interval(time() - $cron->timestamp) ." ago" : "never" )."</TD><TD ALIGN=\"center\"><A HREF=\"admin.php?mod=cron&op=execute&name=$cron->module\">execute</A></TD></TR>\n";
+    $output .= " <TR><TD>". check_output($cron->module) ."</TD><TD><SELECT NAME=\"edit[$cron->module]\">$period</SELECT></TD><TD>". ($cron->timestamp ? format_interval(time() - $cron->timestamp) ." ago" : "never") ."</TD><TD>". ($cron->timestamp ? format_interval($cron->timestamp + $cron->scheduled - time()) ." left" : "never") ."</TD><TD ALIGN=\"center\"><A HREF=\"admin.php?mod=cron&op=execute&name=$cron->module\">execute</A></TD></TR>\n";
     unset($period);
   }
   $output .= "</TABLE>\n";
diff --git a/modules/headline.module b/modules/headline.module
index e4393195bc36edb6a957af97fbac2d838875dcad..df525cac54cd8611a4339aff3ac5367a7cdb1ba9 100644
--- a/modules/headline.module
+++ b/modules/headline.module
@@ -207,7 +207,7 @@ function headline_export($uri) {
     print " <description>$site_name</description>\n";
     print "</channel>\n";
 
-    $result = db_query("SELECT * FROM nodes WHERE type = 'story' AND status = '$status[posted]' ORDER BY timestamp DESC LIMIT 10");
+    $result = db_query("SELECT * FROM node WHERE type = 'story' AND status = '$status[posted]' ORDER BY timestamp DESC LIMIT 10");
 
     while ($node = db_fetch_object($result)) {
       print "<item>\n";
diff --git a/modules/headlineRSS10.module b/modules/headlineRSS10.module
index eacd7c7d5b4c58da5528b50a4f059955378f923e..5714ac9f27a3d54cbc84799eb4218af0860ab28a 100644
--- a/modules/headlineRSS10.module
+++ b/modules/headlineRSS10.module
@@ -32,7 +32,7 @@ function headlineRSS10_export($uri) {
     print "  <items>\n";
     print "    <rdf:Seq>\n";
 
-    $result = db_query("SELECT * FROM nodes WHERE type = 'story' AND status = '$status[posted]' ORDER BY timestamp DESC LIMIT 10");
+    $result = db_query("SELECT * FROM node WHERE type = 'story' AND status = '$status[posted]' ORDER BY timestamp DESC LIMIT 10");
 
     while ($node = db_fetch_object($result)) {
       print "      <rdf:li resource=\"". $site_url ."node.php?id=$node->nid\" />\n";
diff --git a/modules/moderation.module b/modules/moderation.module
index 4b63f0274b5145deb9ecbf190e03d7e8d0bd4df6..4df29e080dd358f04be0add9224d3f5ba5fea325 100644
--- a/modules/moderation.module
+++ b/modules/moderation.module
@@ -12,12 +12,12 @@ function moderation_menu() {
 
 function moderation_count() {
   global $status;
-  $result = db_query("SELECT COUNT(nid) FROM nodes WHERE status = '$status[queued]'");
+  $result = db_query("SELECT COUNT(nid) FROM node WHERE status = '$status[queued]'");
   return ($result) ? db_result($result, 0) : 0;
 }
 
 function moderation_score($id) {
-  $result = db_query("SELECT score FROM nodes WHERE nid = '$id'");
+  $result = db_query("SELECT score FROM node WHERE nid = '$id'");
   return ($result) ? db_result($result, 0) : 0;
 }
 
@@ -26,7 +26,7 @@ function moderation_vote($id, $vote) {
 
   if (!user_get($user, "history", "n$id")) {
     // Update submission's score- and votes-field:
-    db_query("UPDATE nodes SET score = score $vote, votes = votes + 1 WHERE nid = $id");
+    db_query("UPDATE node SET score = score $vote, votes = votes + 1 WHERE nid = $id");
 
     // Update user's history record:
     $user = user_set($user, "history", "n$id", $vote);
@@ -51,7 +51,7 @@ function moderation_vote($id, $vote) {
 function moderation_overview() {
   global $status, $theme, $user;
 
-  $result = db_query("SELECT n.*, u.userid FROM nodes n LEFT JOIN users u ON n.author = u.id WHERE n.status = '$status[queued]'");
+  $result = db_query("SELECT n.*, u.userid FROM node n LEFT JOIN users u ON n.author = u.id WHERE n.status = '$status[queued]'");
 
   $content .= "<TABLE BORDER=\"0\" CELLSPACING=\"4\" CELLPADDING=\"4\">\n";
   $content .= " <TR BGCOLOR=\"$bgcolor1\"><TH>". t("Subject") ."</TH><TH>". t("Author") ."</TH><TH>". t("Type") ."</TH><TH>". t("Score") ."</TH></TR>\n";
diff --git a/modules/rating.module b/modules/rating.module
index 563876bd090c451635bdc86c0e5002662e7dac0d..dfae0759419822e3c06716107920db24a89488da 100644
--- a/modules/rating.module
+++ b/modules/rating.module
@@ -16,12 +16,12 @@ function rating_cron() {
   while ($rating = db_fetch_object($r1)) {
     unset($bonus); unset($votes); unset($score); unset($value); unset($weight);
 
-    $r2 = db_query("SELECT COUNT(nid) AS number FROM nodes WHERE author = '$rating->id' AND (". time() ." - timestamp < $period) AND status = '$status[posted]'");
+    $r2 = db_query("SELECT COUNT(nid) AS number FROM node WHERE author = '$rating->id' AND (". time() ." - timestamp < $period) AND status = '$status[posted]'");
     if ($story = db_fetch_object($r2)) {
       $bonus += $story->number / 2;
     }
 
-    $r3 = db_query("SELECT COUNT(nid) AS number FROM nodes WHERE author = '$rating->id' AND (". time() ." - timestamp < $period) AND status = '$status[dumped]'");
+    $r3 = db_query("SELECT COUNT(nid) AS number FROM node WHERE author = '$rating->id' AND (". time() ." - timestamp < $period) AND status = '$status[dumped]'");
     if ($story = db_fetch_object($r3)) {
       $bonus -= $story->number / 2;
     }
diff --git a/modules/story.module b/modules/story.module
index db2166d152000084eeff4addda7b52b80ba7b364..f47a93e0b629648451e498a68cc5f51223c9c30c 100644
--- a/modules/story.module
+++ b/modules/story.module
@@ -22,16 +22,16 @@ function Story($userid, $title, $abstract, $body, $section, $timestamp) {    $th
 
 function story_cron() {
   global $status;
-  $result = db_query("SELECT * FROM nodes WHERE status = '$status[scheduled]' AND timestamp <= ". time() ."");
+  $result = db_query("SELECT * FROM node WHERE status = '$status[scheduled]' AND timestamp <= ". time() ."");
   while ($story = db_fetch_object($result)) {
-    db_query("UPDATE nodes SET status = '$status[queued]', timestamp = '". time() ."' WHERE nid = '$story->nid' AND type = 'story'");
+    db_query("UPDATE node SET status = '$status[queued]', timestamp = '". time() ."' WHERE nid = '$story->nid' AND type = 'story'");
   }
 }
 
 function story_find($keys) {
   global $status, $user;
   $find = array();
-  $result = db_query("SELECT n.*, s.* FROM story s LEFT JOIN nodes n ON s.node = n.nid WHERE n.status = '$status[posted]' AND (n.title LIKE '%". check_input($keys) ."%' OR s.abstract LIKE '%". check_input($keys) ."%' OR s.body LIKE '%$keys%') LIMIT 20");
+  $result = db_query("SELECT n.*, s.* FROM story s LEFT JOIN node n ON n.nid = s.nid AND n.lid = s.lid WHERE n.status = '$status[posted]' AND (n.title LIKE '%$keys%' OR s.abstract LIKE '%$keys%' OR s.body LIKE '%$keys%') LIMIT 20");
   while ($story = db_fetch_object($result)) {
     array_push($find, array("title" => check_output($story->title), "link" => (user_access($user, "story") ? "admin.php?mod=story&op=edit&id=$story->nid" : "node.php?id=$story->nid"), "user" => $story->userid, "date" => $story->timestamp));
   }
@@ -142,7 +142,7 @@ function story_form($edit = array()) {
     $output .= "<INPUT TYPE=\"hidden\" NAME=\"edit[nid]\" VALUE=\"$edit[nid]\">\n";
   }
 
-  $duplicate = db_result(db_query("SELECT COUNT(nid) FROM nodes WHERE title = '$title'"));
+  $duplicate = db_result(db_query("SELECT COUNT(nid) FROM node WHERE title = '$title'"));
 
   if (!$edit) {
     $output .= "<INPUT TYPE=\"submit\" NAME=\"op\" VALUE=\"". t("Preview") ."\">\n";
@@ -188,7 +188,7 @@ function story_block() {
   // disabled for now
   //
   global $status;
-  $result = db_query("SELECT s.id, COUNT(c.cid) AS comments, s.title FROM story s LEFT JOIN comments c ON s.id = c.lid WHERE s.status = '$status[posted]' AND c.link = 'story' GROUP BY s.id ORDER BY comments DESC LIMIT 10");
+  $result = db_query("SELECT s.lid, COUNT(c.cid) AS comments, s.title FROM story s LEFT JOIN comments c ON s.lid = c.lid WHERE s.status = '$status[posted]' AND c.link = 'story' GROUP BY s.lid ORDER BY comments DESC LIMIT 10");
   while ($story = db_fetch_object($result)) {
     $content .= "<LI><A HREF=\"node.php?id=$story->id\">". check_output($story->title) ."</A><BR><SMALL>(". format_plural($story->comments, "comment", "comments") .")</SMALL></LI>\n";
   }
@@ -199,7 +199,7 @@ function story_block() {
 
   unset($content);
 
-  $result = db_query("SELECT s.id, COUNT(c.cid) AS comments, s.title FROM story s LEFT JOIN comments c ON s.id = c.lid WHERE s.status = '$status[posted]' AND c.link = 'story' AND ". time() ." - s.timestamp < 2419200 GROUP BY s.id ORDER BY comments DESC LIMIT 10");
+  $result = db_query("SELECT s.lid, COUNT(c.cid) AS comments, s.title FROM story s LEFT JOIN comments c ON s.lid = c.lid WHERE s.status = '$status[posted]' AND c.link = 'story' AND ". time() ." - s.timestamp < 2419200 GROUP BY s.lid ORDER BY comments DESC LIMIT 10");
   while ($story = db_fetch_object($result)) {
     $content .= "<LI><A HREF=\"node.php?id=$story->id\">". check_output($story->title) ."</A><BR><SMALL>(". format_plural($story->comments, "comment", "comments") .")</SMALL></LI>\n";
   }
@@ -218,28 +218,28 @@ function story_overview() {
   $output .= "<TABLE BORDER=\"1\" CELLPADDING=\"2\" CELLSPACING=\"2\">\n";
 
   // Queued stories:
-  $result = db_query("SELECT n.*, u.userid FROM nodes n LEFT JOIN users u ON n.author = u.id WHERE n.type = 'story' AND n.status = '$status[queued]' ORDER BY timestamp DESC");
+  $result = db_query("SELECT n.*, u.userid FROM node n LEFT JOIN users u ON n.author = u.id WHERE n.type = 'story' AND n.status = '$status[queued]' ORDER BY timestamp DESC");
   $output .= " <TR><TH COLSPAN=\"6\">queued stories</TH></TR>\n";
   while ($node = db_fetch_object($result)) {
     $output .= " <TR><TD><A HREF=\"node.php?id=$node->nid\">". check_output($node->title) ."</A></TD><TD>". format_username($node->userid) ."</TD><TD>votes: $node->votes, score: $node->score</TD><TD><A HREF=\"node.php?id=$node->nid\">view</A></TD><TD><A HREF=\"admin.php?mod=story&op=edit&id=$node->nid\">edit</A></TD><TD ALIGN=\"center\"><A HREF=\"admin.php?mod=story&op=delete&id=$node->nid\">delete</A></TD></TR>\n";
   }
 
   // Scheduled stories:
-  $result = db_query("SELECT n.*, u.userid FROM nodes n LEFT JOIN users u ON n.author = u.id WHERE n.type = 'story' AND n.status = '$status[scheduled]' ORDER BY timestamp DESC");
+  $result = db_query("SELECT n.*, u.userid FROM node n LEFT JOIN users u ON n.author = u.id WHERE n.type = 'story' AND n.status = '$status[scheduled]' ORDER BY timestamp DESC");
   $output .= " <TR><TH COLSPAN=\"6\">scheduled stories</TH></TR>\n";
   while ($node = db_fetch_object($result)) {
     $output .= " <TR><TD><A HREF=\"node.php?id=$node->nid\">". check_output($node->title) ."</A></TD><TD>". format_username($node->userid) ."</TD><TD>". format_date($node->timestamp, "small") ."<BR><SMALL>(". format_interval($node->timestamp - time()) ." left)</SMALL></TD><TD><A HREF=\"node.php?id=$node->nid\">view</A></TD><TD><A HREF=\"admin.php?mod=story&op=edit&id=$node->nid\">edit</A></TD><TD ALIGN=\"center\"><A HREF=\"admin.php?mod=story&op=delete&id=$node->nid\">delete</A></TD></TR>\n";
   }
 
   // Dumped stories:
-  $result = db_query("SELECT n.*, u.userid FROM nodes n LEFT JOIN users u ON n.author = u.id WHERE n.type = 'story' AND n.status = '$status[dumped]' ORDER BY timestamp DESC LIMIT 5");
+  $result = db_query("SELECT n.*, u.userid FROM node n LEFT JOIN users u ON n.author = u.id WHERE n.type = 'story' AND n.status = '$status[dumped]' ORDER BY timestamp DESC LIMIT 5");
   $output .= " <TR><TH COLSPAN=\"6\">dumped stories</TH></TR>\n";
   while ($node = db_fetch_object($result)) {
     $output .= " <TR><TD><A HREF=\"node.php?id=$node->nid\">". check_output($node->title) ."</A></TD><TD>". format_username($node->userid) ."</TD><TD>". format_date($node->timestamp, "small") ."</TD><TD><A HREF=\"node.php?id=$node->nid\">view</A></TD><TD><A HREF=\"admin.php?mod=story&op=edit&id=$node->nid\">edit</A></TD><TD ALIGN=\"center\"><A HREF=\"admin.php?mod=story&op=delete&id=$node->nid\">delete</A></TD></TR>\n";
   }
 
   // Posted stories:
-  $result = db_query("SELECT n.*, u.userid FROM nodes n LEFT JOIN users u ON n.author = u.id WHERE n.type = 'story' AND n.status = '$status[posted]' ORDER BY timestamp DESC LIMIT 15");
+  $result = db_query("SELECT n.*, u.userid FROM node n LEFT JOIN users u ON n.author = u.id WHERE n.type = 'story' AND n.status = '$status[posted]' ORDER BY timestamp DESC LIMIT 15");
   $output .= " <TR><TH COLSPAN=\"6\">posted stories</TH></TR>\n";
   while ($node = db_fetch_object($result)) {
     $output .= " <TR><TD><A HREF=\"node.php?id=$node->nid\">". check_output($node->title) ."</A></TD><TD>". format_username($node->userid) ."</TD><TD>". format_date($node->timestamp, "small") ."</TD><TD><A HREF=\"node.php?id=$node->nid\">view</A></TD><TD><A HREF=\"admin.php?mod=story&op=edit&id=$node->nid\">edit</A></TD><TD ALIGN=\"center\"><A HREF=\"admin.php?mod=story&op=delete&id=$node->nid\">delete</A></TD></TR>\n";
diff --git a/modules/story/story.module b/modules/story/story.module
index db2166d152000084eeff4addda7b52b80ba7b364..f47a93e0b629648451e498a68cc5f51223c9c30c 100644
--- a/modules/story/story.module
+++ b/modules/story/story.module
@@ -22,16 +22,16 @@ function Story($userid, $title, $abstract, $body, $section, $timestamp) {    $th
 
 function story_cron() {
   global $status;
-  $result = db_query("SELECT * FROM nodes WHERE status = '$status[scheduled]' AND timestamp <= ". time() ."");
+  $result = db_query("SELECT * FROM node WHERE status = '$status[scheduled]' AND timestamp <= ". time() ."");
   while ($story = db_fetch_object($result)) {
-    db_query("UPDATE nodes SET status = '$status[queued]', timestamp = '". time() ."' WHERE nid = '$story->nid' AND type = 'story'");
+    db_query("UPDATE node SET status = '$status[queued]', timestamp = '". time() ."' WHERE nid = '$story->nid' AND type = 'story'");
   }
 }
 
 function story_find($keys) {
   global $status, $user;
   $find = array();
-  $result = db_query("SELECT n.*, s.* FROM story s LEFT JOIN nodes n ON s.node = n.nid WHERE n.status = '$status[posted]' AND (n.title LIKE '%". check_input($keys) ."%' OR s.abstract LIKE '%". check_input($keys) ."%' OR s.body LIKE '%$keys%') LIMIT 20");
+  $result = db_query("SELECT n.*, s.* FROM story s LEFT JOIN node n ON n.nid = s.nid AND n.lid = s.lid WHERE n.status = '$status[posted]' AND (n.title LIKE '%$keys%' OR s.abstract LIKE '%$keys%' OR s.body LIKE '%$keys%') LIMIT 20");
   while ($story = db_fetch_object($result)) {
     array_push($find, array("title" => check_output($story->title), "link" => (user_access($user, "story") ? "admin.php?mod=story&op=edit&id=$story->nid" : "node.php?id=$story->nid"), "user" => $story->userid, "date" => $story->timestamp));
   }
@@ -142,7 +142,7 @@ function story_form($edit = array()) {
     $output .= "<INPUT TYPE=\"hidden\" NAME=\"edit[nid]\" VALUE=\"$edit[nid]\">\n";
   }
 
-  $duplicate = db_result(db_query("SELECT COUNT(nid) FROM nodes WHERE title = '$title'"));
+  $duplicate = db_result(db_query("SELECT COUNT(nid) FROM node WHERE title = '$title'"));
 
   if (!$edit) {
     $output .= "<INPUT TYPE=\"submit\" NAME=\"op\" VALUE=\"". t("Preview") ."\">\n";
@@ -188,7 +188,7 @@ function story_block() {
   // disabled for now
   //
   global $status;
-  $result = db_query("SELECT s.id, COUNT(c.cid) AS comments, s.title FROM story s LEFT JOIN comments c ON s.id = c.lid WHERE s.status = '$status[posted]' AND c.link = 'story' GROUP BY s.id ORDER BY comments DESC LIMIT 10");
+  $result = db_query("SELECT s.lid, COUNT(c.cid) AS comments, s.title FROM story s LEFT JOIN comments c ON s.lid = c.lid WHERE s.status = '$status[posted]' AND c.link = 'story' GROUP BY s.lid ORDER BY comments DESC LIMIT 10");
   while ($story = db_fetch_object($result)) {
     $content .= "<LI><A HREF=\"node.php?id=$story->id\">". check_output($story->title) ."</A><BR><SMALL>(". format_plural($story->comments, "comment", "comments") .")</SMALL></LI>\n";
   }
@@ -199,7 +199,7 @@ function story_block() {
 
   unset($content);
 
-  $result = db_query("SELECT s.id, COUNT(c.cid) AS comments, s.title FROM story s LEFT JOIN comments c ON s.id = c.lid WHERE s.status = '$status[posted]' AND c.link = 'story' AND ". time() ." - s.timestamp < 2419200 GROUP BY s.id ORDER BY comments DESC LIMIT 10");
+  $result = db_query("SELECT s.lid, COUNT(c.cid) AS comments, s.title FROM story s LEFT JOIN comments c ON s.lid = c.lid WHERE s.status = '$status[posted]' AND c.link = 'story' AND ". time() ." - s.timestamp < 2419200 GROUP BY s.lid ORDER BY comments DESC LIMIT 10");
   while ($story = db_fetch_object($result)) {
     $content .= "<LI><A HREF=\"node.php?id=$story->id\">". check_output($story->title) ."</A><BR><SMALL>(". format_plural($story->comments, "comment", "comments") .")</SMALL></LI>\n";
   }
@@ -218,28 +218,28 @@ function story_overview() {
   $output .= "<TABLE BORDER=\"1\" CELLPADDING=\"2\" CELLSPACING=\"2\">\n";
 
   // Queued stories:
-  $result = db_query("SELECT n.*, u.userid FROM nodes n LEFT JOIN users u ON n.author = u.id WHERE n.type = 'story' AND n.status = '$status[queued]' ORDER BY timestamp DESC");
+  $result = db_query("SELECT n.*, u.userid FROM node n LEFT JOIN users u ON n.author = u.id WHERE n.type = 'story' AND n.status = '$status[queued]' ORDER BY timestamp DESC");
   $output .= " <TR><TH COLSPAN=\"6\">queued stories</TH></TR>\n";
   while ($node = db_fetch_object($result)) {
     $output .= " <TR><TD><A HREF=\"node.php?id=$node->nid\">". check_output($node->title) ."</A></TD><TD>". format_username($node->userid) ."</TD><TD>votes: $node->votes, score: $node->score</TD><TD><A HREF=\"node.php?id=$node->nid\">view</A></TD><TD><A HREF=\"admin.php?mod=story&op=edit&id=$node->nid\">edit</A></TD><TD ALIGN=\"center\"><A HREF=\"admin.php?mod=story&op=delete&id=$node->nid\">delete</A></TD></TR>\n";
   }
 
   // Scheduled stories:
-  $result = db_query("SELECT n.*, u.userid FROM nodes n LEFT JOIN users u ON n.author = u.id WHERE n.type = 'story' AND n.status = '$status[scheduled]' ORDER BY timestamp DESC");
+  $result = db_query("SELECT n.*, u.userid FROM node n LEFT JOIN users u ON n.author = u.id WHERE n.type = 'story' AND n.status = '$status[scheduled]' ORDER BY timestamp DESC");
   $output .= " <TR><TH COLSPAN=\"6\">scheduled stories</TH></TR>\n";
   while ($node = db_fetch_object($result)) {
     $output .= " <TR><TD><A HREF=\"node.php?id=$node->nid\">". check_output($node->title) ."</A></TD><TD>". format_username($node->userid) ."</TD><TD>". format_date($node->timestamp, "small") ."<BR><SMALL>(". format_interval($node->timestamp - time()) ." left)</SMALL></TD><TD><A HREF=\"node.php?id=$node->nid\">view</A></TD><TD><A HREF=\"admin.php?mod=story&op=edit&id=$node->nid\">edit</A></TD><TD ALIGN=\"center\"><A HREF=\"admin.php?mod=story&op=delete&id=$node->nid\">delete</A></TD></TR>\n";
   }
 
   // Dumped stories:
-  $result = db_query("SELECT n.*, u.userid FROM nodes n LEFT JOIN users u ON n.author = u.id WHERE n.type = 'story' AND n.status = '$status[dumped]' ORDER BY timestamp DESC LIMIT 5");
+  $result = db_query("SELECT n.*, u.userid FROM node n LEFT JOIN users u ON n.author = u.id WHERE n.type = 'story' AND n.status = '$status[dumped]' ORDER BY timestamp DESC LIMIT 5");
   $output .= " <TR><TH COLSPAN=\"6\">dumped stories</TH></TR>\n";
   while ($node = db_fetch_object($result)) {
     $output .= " <TR><TD><A HREF=\"node.php?id=$node->nid\">". check_output($node->title) ."</A></TD><TD>". format_username($node->userid) ."</TD><TD>". format_date($node->timestamp, "small") ."</TD><TD><A HREF=\"node.php?id=$node->nid\">view</A></TD><TD><A HREF=\"admin.php?mod=story&op=edit&id=$node->nid\">edit</A></TD><TD ALIGN=\"center\"><A HREF=\"admin.php?mod=story&op=delete&id=$node->nid\">delete</A></TD></TR>\n";
   }
 
   // Posted stories:
-  $result = db_query("SELECT n.*, u.userid FROM nodes n LEFT JOIN users u ON n.author = u.id WHERE n.type = 'story' AND n.status = '$status[posted]' ORDER BY timestamp DESC LIMIT 15");
+  $result = db_query("SELECT n.*, u.userid FROM node n LEFT JOIN users u ON n.author = u.id WHERE n.type = 'story' AND n.status = '$status[posted]' ORDER BY timestamp DESC LIMIT 15");
   $output .= " <TR><TH COLSPAN=\"6\">posted stories</TH></TR>\n";
   while ($node = db_fetch_object($result)) {
     $output .= " <TR><TD><A HREF=\"node.php?id=$node->nid\">". check_output($node->title) ."</A></TD><TD>". format_username($node->userid) ."</TD><TD>". format_date($node->timestamp, "small") ."</TD><TD><A HREF=\"node.php?id=$node->nid\">view</A></TD><TD><A HREF=\"admin.php?mod=story&op=edit&id=$node->nid\">edit</A></TD><TD ALIGN=\"center\"><A HREF=\"admin.php?mod=story&op=delete&id=$node->nid\">delete</A></TD></TR>\n";
diff --git a/node.php b/node.php
index 0bb55f635b9cea4c627238e66cdad4ca4fd453c8..79f4b4a878397be336d8de7d7898590ad48adbe5 100644
--- a/node.php
+++ b/node.php
@@ -2,6 +2,13 @@
 
 include "includes/common.inc";
 
+function node_failure() {
+  global $theme;
+  $theme->header();
+  $theme->box(t("Warning: not found"), t("The content or data you requested does not exist or is not accessible."));
+  $theme->footer();
+}
+
 function node_history($node) {
   global $status;
   if ($node->status == $status[expired] || $node->status == $status[posted]) {
@@ -13,28 +20,37 @@ function node_history($node) {
   return $output;
 }
 
-function node_refers($node) {
-  print "under construction";
-}
+$number = ($title ? db_result(db_query("SELECT COUNT(nid) FROM node WHERE title = '$title' AND status = $status[posted]", 1)) : 1);
 
-$node = ($title ? node_get_object(title, check_input($title)) : node_get_object(nid, check_input($id)));
-
-if ($node && node_visible($node)) {
-  switch ($op) {
-    case "history":
-      $theme->header();
-      $theme->box(t("History"), node_info($node) ."<DL>". node_history($node) ."</DL>");
-      $theme->footer();
-      break;
-    default:
-      if ($user->id) user_load($user->userid);
-      node_view($node, 1);
+if ($number > 1) {
+  $result = db_query("SELECT n.*, u.userid FROM node n LEFT JOIN users u ON n.author = u.id WHERE n.title = '$title'");
+
+  while ($node = db_fetch_object($result)) {
+    if (node_visible($node)) {
+      $output .= "<P><B><A HREF=\"node.php?id=$node->nid\">". check_output($node->title) ."</A></B><BR><SMALL>$node->type - ". format_username($node->userid) ." - ". format_date($node->timestamp, "small") ."</SMALL></P>";
+    }
   }
-}
-else {
+
   $theme->header();
-  $theme->box(t("Warning: not found"), t("The content or data you requested does not exist or is not accessible."));
+  $theme->box(t("Result"), $output);
   $theme->footer();
 }
+elseif ($number) {
+  $node = ($title ? node_get_object(title, check_input($title)) : node_get_object(nid, check_input($id)));
+  if ($node && node_visible($node)) {
+    switch ($op) {
+      case "history":
+        $theme->header();
+        $theme->box(t("History"), node_info($node) ."<DL>". node_history($node) ."</DL>");
+        $theme->footer();
+        break;
+      default:
+        if ($user->id) user_load($user->userid);
+        node_view($node, 1);
+    }
+  }
+  else node_failure();
+}
+else node_failure();
 
 ?>
\ No newline at end of file
diff --git a/search.php b/search.php
index 0ca1a2fffe116cadda06cbb67468e21bd9958bf4..4a7831babece012fe4cea217093611102aff479f 100644
--- a/search.php
+++ b/search.php
@@ -15,7 +15,7 @@ function find_module($name, $module) {
 $search .= " <INPUT TYPE=\"submit\" VALUE=\"". t("Search") ."\">\n";
 $search .= "</FORM>\n";
 
-$output = search_data(check_input($keys), check_input($type));
+$output = search_data($keys, $type);
 
 $theme->header();
 $theme->box(t("Search"), $search);
diff --git a/updates/2.00-to-x.xx.php b/updates/2.00-to-x.xx.php
index 2d5050cd268c22470803437a7eba423851b3fd69..da2e3928b6757ac379a0c84b0465aadfadff4da5 100644
--- a/updates/2.00-to-x.xx.php
+++ b/updates/2.00-to-x.xx.php
@@ -3,7 +3,7 @@
 include "includes/common.inc";
 
 db_query("DELETE FROM watchdog");
-db_query("DELETE FROM nodes");
+db_query("DELETE FROM node");
 db_query("DELETE FROM story");
 db_query("DELETE FROM book");
 
diff --git a/updates/2.00-to-x.xx.sql b/updates/2.00-to-x.xx.sql
index 264a823aebad4225e0b7c8ef4e798f3e391c93c5..4f20acbdf50163d6dacb95f8a00c32cc16ddfa53 100644
--- a/updates/2.00-to-x.xx.sql
+++ b/updates/2.00-to-x.xx.sql
@@ -1,27 +1,27 @@
-# 25/03/2001:
+# 30/03/2001:
 CREATE TABLE book (
-  id int(10) unsigned DEFAULT '0' NOT NULL auto_increment,
-  node int(10) unsigned DEFAULT '0' NOT NULL,
+  lid int(10) unsigned DEFAULT '0' NOT NULL auto_increment,
+  nid int(10) unsigned DEFAULT '0' NOT NULL,
   body text NOT NULL,
   section int(10) DEFAULT '0' NOT NULL,
   parent int(10) DEFAULT '0' NOT NULL,
   weight tinyint(3) DEFAULT '0' NOT NULL,
-  PRIMARY KEY (id)
+  PRIMARY KEY (lid)
 );
 
 CREATE TABLE story (
-  id int(10) unsigned DEFAULT '0' NOT NULL auto_increment,
-  node int(10) unsigned DEFAULT '0' NOT NULL,
+  lid int(10) unsigned DEFAULT '0' NOT NULL auto_increment,
+  nid int(10) unsigned DEFAULT '0' NOT NULL,
   abstract text NOT NULL,
   body text NOT NULL,
   section varchar(64) DEFAULT '' NOT NULL,
-  PRIMARY KEY (id)
+  PRIMARY KEY (lid)
 );
 
-CREATE TABLE nodes (
+CREATE TABLE node (
   nid int(10) unsigned DEFAULT '0' NOT NULL auto_increment,
-  lid int(6) DEFAULT '0' NOT NULL,
-  pid int(6) DEFAULT '0' NOT NULL,
+  lid int(10) DEFAULT '0' NOT NULL,
+  pid int(10) DEFAULT '0' NOT NULL,
   log text NOT NULL,
   type varchar(16) DEFAULT '' NOT NULL,
   title varchar(128) DEFAULT '' NOT NULL,