diff --git a/README.txt b/README.txt
old mode 100644
new mode 100755
index c66a6d2..41ca102
--- a/README.txt
+++ b/README.txt
@@ -1,3 +1,7 @@
+--- d7 upgrade -- 
+This module requires http://drupal.org/project/menu_block
+This module handles 'book page' titles, but requires the menu block to create a 
+list. Again this module doesn't rewrite the titles of book's default block.    
 
 -- SUMMARY --
 
diff --git a/bookchapters.info b/bookchapters.info
old mode 100644
new mode 100755
index 8bd4070..5ae6513
--- a/bookchapters.info
+++ b/bookchapters.info
@@ -1,6 +1,9 @@
 name = Book Chapters
 description = Set chapter numbering for book hierarchies.
 dependencies[] = book
+dependencies[] = menu_block
 package = Book
-version = VERSION
-core = 6.x
+version = 7.x-beta
+core = 7.x
+files[] = bookchapters.module
+
diff --git a/bookchapters.module b/bookchapters.module
old mode 100644
new mode 100755
index abbac0d..f61dc75
--- a/bookchapters.module
+++ b/bookchapters.module
@@ -6,37 +6,38 @@
  */
 
 /**
- * Implementation of hook_nodeapi().
+ * Implementation of hook_node_load().
  *
+ * Dynamically modify title. Add numbering to the beginning.
  */
-function bookchapters_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
-  switch ($op) {
-
-    case 'load':
-    case 'prepare':
-      $numbering = _bookchapters_get_chapter_numbering($node->nid);
-      if (!empty($numbering)) {
-        if ($op == 'load') {
-          //Dynamically modify title. Add numbering to the beginning.
-          $node->title = "$numbering " . $node->title;
-        }
-        else if ($op == 'prepare' && strpos($node->title, $numbering) === 0) {
-          //Numbering must be removed when viewing node edit form.
-          //Otherwise it would be stored to database together with title.
-          $node->title = drupal_substr($node->title, drupal_strlen($numbering)+1);
-        }
-      }
-      break;
+function bookchapters_node_load($nodes, $types) {
+  // IGNORE ADMIN PAGES - Updating on publishing from the admin/content pages stores the numbering to databases 
+  if ( stripos(drupal_get_path_alias($_GET['q']), 'admin')===0) { return; } 
+  
+  foreach ( $nodes as $node ) {
+    $node->title = _bookchapters_get_chapter_numbering($node->nid) ." ". $node->title;
+  }
+}
 
-    default:
-      break;
-    
+function bookchapters_node_prepare($node) {
+  // IGNORE ADMIN PAGES
+  if ( stripos(drupal_get_path_alias($_GET['q']), 'admin')===0 ) { return; } 
+  //Numbering must be removed when viewing node edit form.
+  //Otherwise it would be stored to database together with title.
+  
+  if( isset($node->nid) ) {
+    $numbering = _bookchapters_get_chapter_numbering($node->nid);
+    if ( !empty($numbering) && (strpos($node->title, $numbering) === 0) ){
+      $node->title = drupal_substr($node->title, drupal_strlen( $numbering )+1);
+    }
   }
 }
 
 /**
  * Alter the menu tree and its configuration before the tree is rendered.
  *
+ * This uses a hook from module menu_block
+ * 
  * @param $tree
  *   An array containing the unrendered menu tree.
  * @param $config
@@ -46,7 +47,7 @@ function bookchapters_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
 function bookchapters_menu_block_tree_alter(&$tree, &$config) {
   $book_menus = array();
   $result = db_query("SELECT menu_name FROM {menu_links} WHERE module = 'book' GROUP BY menu_name");
-  while ($menu_name = db_result($result)) {
+  while ($menu_name = $result->fetchField()) {
     $book_menus[] = $menu_name;
   }
 
@@ -73,20 +74,21 @@ function _bookchapters_rewrite_menu_link_title(&$item) {
 }
 
 function _bookchapters_get_chapter_numbering($nid) {
-  static $ret_values;
+  static $bookchapter_values;
 
-  if (empty($ret_values)) {
-    $ret_values = array();
+  if (empty($bookchapter_values)) {
+    $bookchapter_values = array();
   }
 
-  if (isset($ret_values[$nid])) {
-    return $ret_values[$nid];
+  if (isset($bookchapter_values[$nid])) {
+    return $bookchapter_values[$nid];
   }
-
-  $book_info = db_fetch_array(db_query('SELECT * FROM {book} b INNER JOIN {menu_links} ml ON b.mlid = ml.mlid WHERE b.nid = %d', $nid));
+  
+  $book_info = db_query('SELECT * FROM {book} b INNER JOIN {menu_links} ml ON b.mlid = ml.mlid WHERE b.nid = :nid', array(':nid'=>$nid) )->fetchAssoc();
+  
   if (!empty($book_info)) {
-    $ret_values[$nid] = _bookchapters_get_chapter_numbering_recursive($book_info['menu_name'], $book_info['plid'], $book_info['mlid']);
-    return $ret_values[$nid];
+    $bookchapter_values[$nid] = _bookchapters_get_chapter_numbering_recursive($book_info['menu_name'], $book_info['plid'], $book_info['mlid']);
+    return $bookchapter_values[$nid];
   }
 }
 
@@ -94,19 +96,20 @@ function _bookchapters_get_chapter_numbering_recursive($menu_name, $plid, $mlid)
   if (empty($menu_name) || empty($plid) || empty($mlid)) {
     return;
   }
-
-  $result = db_query('SELECT * FROM {menu_links} WHERE menu_name = "%s" AND plid = %d ORDER BY weight ASC, link_title ASC',
-                            $menu_name, //to gain performance benefits filter using primary key field
-                            $plid);
+  //to gain performance benefits filter using primary key field
+  $result = db_query('SELECT * FROM {menu_links} WHERE menu_name =:menu_name AND plid = :plid ORDER BY weight ASC, link_title ASC',
+                            array( ':menu_name'=> $menu_name, ':plid'=>$plid) );
   $order_number = 1;
-  while ($row = db_fetch_array($result)) {
+  while ($row=$result->fetchAssoc()) {
     if ($row['mlid'] == $mlid) {
       if ($row['plid'] > 0) {
-        $parent = db_fetch_array(db_query('SELECT * FROM {menu_links} WHERE menu_name = "%s" AND mlid = %d', $menu_name, $row['plid']));
+        $parent = db_query('SELECT * FROM {menu_links} WHERE menu_name = :menu_name AND mlid = :mlid', array(":menu_name" => $menu_name, ":mlid" => $row['plid']) )->fetchAssoc();
         if ($parent['plid'] > 0) {
           $parent_order_number = _bookchapters_get_chapter_numbering_recursive($menu_name, $parent['plid'], $parent['mlid']);
         }
-        $order_number = $parent_order_number? "$parent_order_number.$order_number" : $order_number;
+        if ( isset( $parent_order_number ) && ! empty($parent_order_number) ) { 
+          $order_number = "$parent_order_number.$order_number"; 
+        }
       }
       return $order_number;
     }
