diff -urp type_local_nids-orig/type_local_nids.install type_local_nids/type_local_nids.install
--- type_local_nids-orig/type_local_nids.install	2009-11-28 20:26:58.000000000 +1100
+++ type_local_nids/type_local_nids.install	2010-01-08 08:44:09.850528200 +1100
@@ -1,66 +1,65 @@
 <?php
 // $Id: type_local_nids.install,v 1.1.2.2 2009/11/28 09:26:58 jbrown Exp $
-
+/**
+ * @file
+ * Install, update and uninstall functions for the Type-local nids module.
+ */
 
 /**
- * Implement hook_schema() .
+ * Implements hook_schema().
  */
 function type_local_nids_schema() {
-
-	$schema['node_lnid_next'] = array(
-		'description' => t('Maintains the next lnid for each node type.'),
-		'fields' => array(
-			'type' => array(
-				'description' => t('The node type.'),
-				'type' => 'varchar',
-				'length' => 32,
-				'not null' => TRUE
-			),
-			'next_lnid' => array(
-				'description' => t('The next lnid.'),
+  $schema['node_lnid_next'] = array(
+    'description' => t('Maintains the next lnid for each node type.'),
+    'fields' => array(
+      'type' => array(
+        'description' => t('The node type.'),
+        'type' => 'varchar',
+        'length' => 32,
+        'not null' => TRUE
+      ),
+      'next_lnid' => array(
+        'description' => t('The next lnid.'),
         'type' => 'int',
         'unsigned' => TRUE,
         'not null' => TRUE
-			)
-		),
-		'primary key' => array('type')
-	);
-
-	$schema['node_lnid'] = array(
-		'description' => t('Maintains the lnid for each node'),
-		'fields' => array(
-			'nid' => array(
-				'description' => t('The nid.'),
+      )
+    ),
+    'primary key' => array('type')
+  );
+
+  $schema['node_lnid'] = array(
+    'description' => t('Maintains the lnid for each node'),
+    'fields' => array(
+      'nid' => array(
+        'description' => t('The nid.'),
         'type' => 'int',
         'unsigned' => TRUE,
         'not null' => TRUE
-			),
-			'lnid' => array(
-				'description' => t('The lnid.'),
+      ),
+      'lnid' => array(
+        'description' => t('The lnid.'),
         'type' => 'int',
         'unsigned' => TRUE,
         'not null' => TRUE
-			)
-		),
-		'primary key' => array('nid')
-	);
+      )
+    ),
+    'primary key' => array('nid')
+  );
 
-	return $schema;
+  return $schema;
 }
 
-
 /**
- * Implement hook_install() .
+ * Implements hook_install().
  */
 function type_local_nids_install() {
-	drupal_install_schema('type_local_nids');
+  drupal_install_schema('type_local_nids');
 }
 
-
 /**
- * Implement hook_uninstall() .
+ * Implements hook_uninstall().
  */
 function type_local_nids_uninstall() {
-	drupal_uninstall_schema('type_local_nids');
+  drupal_uninstall_schema('type_local_nids');
 }
-
diff -urp type_local_nids-orig/type_local_nids.module type_local_nids/type_local_nids.module
--- type_local_nids-orig/type_local_nids.module	2009-11-28 20:26:58.000000000 +1100
+++ type_local_nids/type_local_nids.module	2010-01-08 08:43:52.115358700 +1100
@@ -1,141 +1,95 @@
 <?php
-// $Id: type_local_nids.module,v 1.1.2.7 2009/11/28 09:26:58 jbrown Exp $
-
+// $Id: type_local_nids.module,v 1.1.2.6 2009/11/17 07:54:36 jbrown Exp $
+/**
+ * @file
+ * Contains core functions for the Type-local nids module.
+ */
 
 function _type_local_nids_get_lnid(&$node) {
+  $node->lnid = db_result(db_query(
+    "SELECT lnid FROM {node_lnid} WHERE nid = %d", $node->nid
+  ));
 
-	$node->lnid = db_result(db_query("
-		SELECT lnid
-		FROM {node_lnid}
-		WHERE nid = %d
-	",
-		$node->nid
-	));
-	
-	if($node->lnid)
-	  return;
-
-	$node->lnid = db_result(db_query("
-		SELECT next_lnid
-		FROM {node_lnid_next}
-		WHERE type = '%s'
-	",
-		$node->type
-	));
-
-	if($node->lnid) {
-
-		db_query("
-			UPDATE {node_lnid_next}
-			SET next_lnid = next_lnid + 1
-			WHERE type = '%s'
-		",
-			$node->type
-		);
-	}
-	else {
-	  $node_lnid_next = array(
-	    'type' => $node->type,
-	    'next_lnid' => 2
-	  );
-	  
-	  drupal_write_record('node_lnid_next', $node_lnid_next);
-		
-		$node->lnid = 1;
-	}
-	
-	drupal_write_record('node_lnid', $node);
-}
+  if ($node->lnid) {
+    return;
+  }
 
+  $node->lnid = db_result(db_query(
+    "SELECT next_lnid FROM {node_lnid_next} WHERE type = '%s'", $node->type
+  ));
+
+  if ($node->lnid) {
+    db_query(
+      "UPDATE {node_lnid_next} SET next_lnid = next_lnid + 1 WHERE type = '%s'", $node->type
+    );
+  }
 
-/**
- * Implement hook_nodeapi() .
- */
-function type_local_nids_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
+  else {
+    $node_lnid_next = array(
+      'type' => $node->type,
+      'next_lnid' => 2
+    );
+    drupal_write_record('node_lnid_next', $node_lnid_next);
+    $node->lnid = 1;
+  }
 
-	switch ($op) {
-	
-		case 'insert':
-		case 'update':
-		case 'load':
-
-			_type_local_nids_get_lnid($node);
-
-			return array('lnid' => $node->lnid);
-
-
-		case 'delete':
-		
-			db_query("
-				DELETE FROM {node_lnid}
-				WHERE nid = %d
-			",
-				$node->nid
-			);
-			
-			break;
-	}
+  drupal_write_record('node_lnid', $node);
 }
 
-
 /**
- * Implement hook_node_type() .
+ * Implements hook_nodeapi().
  */
-function type_local_nids_node_type($op, $info) {
-
-	switch ($op){
-
-		case 'delete':
-
-			db_query("
-				DELETE FROM {node_lnid_next}
-				WHERE type = '%s'
-			",
-				$info->type
-			);
-
-			break;
-
-
-		case 'update':
-		
-			if(!empty($info->old_type) && $info->old_type != $info->type) {
-			
-				db_query("
-					UPDATE {node_lnid_next}
-					SET type = '%s'
-					WHERE type = '%s'
-				",
-					$info->type, 
-					$info->old_type
-				);
-			}
-			
-			break;
-	}
+function type_local_nids_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
+  switch ($op) {
+    case 'insert':
+    case 'update':
+    case 'load':
+      _type_local_nids_get_lnid($node);
+      return array('lnid' => $node->lnid);
+
+    case 'delete':
+      db_query(
+        "DELETE FROM {node_lnid} WHERE nid = %d", $node->nid
+      );
+      break;
+  }
 }
 
+function type_local_nids_node_type($op, $info) {
+  switch ($op) {
+    case 'delete':
+      db_query(
+        "DELETE FROM {node_lnid_next} WHERE type = '%s'", $info->type
+      );
+      break;
+
+    case 'update':
+      if (!empty($info->old_type) && $info->old_type != $info->type) {
+        db_query(
+          "UPDATE {node_lnid_next} SET type = '%s' WHERE type = '%s'",
+          $info->type, $info->old_type
+        );
+      }
+      break;
+  }
+}
 
 /**
- * Implement hook_token_values() .
+ * Implements hook_token_values().
  */
 function type_local_nids_token_values($type, $object = NULL, $options = array()) {
-
-  if($type == 'node') {
+  if ($type == 'node') {
     $tokens['lnid'] = $object->lnid;
     return $tokens;
   }
 }
 
-
 /**
- * Implement hook_token_list() .
+ * Implements hook_token_list().
  */
 function type_local_nids_token_list($type = 'all') {
-
-  if($type == 'node' || $type == 'all') {
+  if ($type == 'node' || $type == 'all') {
     $tokens['node']['lnid'] = t("The type-local nid.");
     return $tokens;
   }
 }
-
