diff -urp uuid.beta2/uuid.admin.inc uuid/uuid.admin.inc
--- uuid.beta2/uuid.admin.inc	2010-09-08 12:07:14.000000000 -0400
+++ uuid/uuid.admin.inc	2010-09-21 20:13:02.000000000 -0400
@@ -10,8 +10,31 @@
  * Menu callback: options for UUID.
  */
 function uuid_admin() {
-  $form = array();
 
+  $form = array();
+  
+  $form['format'] = array(
+  	'#type' => 'fieldset',
+  	'#title' => t('UUID Format'),
+  	'#collapsible' => TRUE,
+  	'#collapsed' => TRUE
+  );
+  $form['format']['uuid_namespace'] = array(
+  	'#type' => 'textfield',
+  	'#title' => t('UUID Namespace'),
+  	'#default_value' => variable_get('uuid_namespace', uuid_uuid()),
+  	'#description' => t('The namespace must be in a RFC 4211 compliant UUID format. Most people will want to leave this alone as it is generated during the installation of the module. It is only relevant for v3 and v5 UUIDs.')
+  );
+	$form['format']['uuid_version'] = array(
+		'#type' => 'select',
+		'#options' => array(
+			'v3' => t('Version 3 (namespace and prefix)'), 
+			'v4' => t('Version 4 (pseudo random)'), 
+			'v5' => t('Version 5 (namespace and prefix)')
+		),
+		'#title' => t('UUID Version'),
+		'#default_value' => variable_get('uuid_version', UUID_VERSION_DEFAULT),
+	);
   $form['content'] = array(
     '#type' => 'fieldset',
     '#title' => t('Content settings'),
@@ -25,6 +48,15 @@ function uuid_admin() {
     '#description' => t('Content of these types will have UUIDs automatically generated.'),
     '#required' => FALSE,
   );
+  /** @todo currently, the sync method is only additive. If
+   * a node type is deactivated, revisions of the nodes will
+   * still have uuids. Shouldn't the sync method remove uuids
+   * for content that has been unchecked, including
+   * revisions?
+   * Proposed: Add a submit handler to this element, and
+   * expand the sync function to remove uuids for types that
+   * have been deactivated.
+   */
 
   $form['user'] = array(
     '#type' => 'fieldset',
@@ -122,15 +154,16 @@ function uuid_sync() {
     $placeholders = db_placeholders($types, 'varchar');
 
     // Nodes.
-    $result = db_query("SELECT nid FROM {node} WHERE type IN (" . $placeholders . ") AND nid NOT IN (SELECT nid FROM {uuid_node})", $types);
+    $result = db_query('SELECT n.nid FROM node AS n	LEFT JOIN uuid_node AS un ON un.nid=n.nid	WHERE type IN ('. $placeholders .') AND un.nid IS NULL;', $types);
     while ($item = db_fetch_object($result)) {
       db_query("INSERT INTO {uuid_node} (nid, uuid) VALUES(%d, '%s')", $item->nid, uuid_uuid());
     }
 
     // Revisions.
-    $result = db_query("SELECT nr.vid AS vid FROM {node_revisions} AS nr INNER JOIN {node} n ON nr.nid = n.nid WHERE n.type IN (" . $placeholders . ") AND nr.vid NOT IN (SELECT vid FROM {uuid_node_revisions})", $types);
+    $result = db_query('SELECT nr.vid AS vid, nr.nid AS nid FROM {node_revisions} AS nr INNER JOIN {node} n ON nr.nid = n.nid LEFT JOIN {uuid_node_revisions} AS unr ON unr.nid=nr.nid AND unr.vid=nr.vid WHERE 
+		n.type IN ('. $placeholders .') AND	unr.nid IS NULL', $types);
     while ($item = db_fetch_object($result)) {
-      db_query("INSERT INTO {uuid_node_revisions} (vid, uuid) VALUES(%d, '%s')", $item->vid, uuid_uuid());
+      db_query("INSERT INTO {uuid_node_revisions} (vid, uuid, nid) VALUES(%d, '%s', %d)", $item->vid, uuid_uuid(), $item->nid);
     }
   }
 
Only in uuid: uuid.class.inc
diff -urp uuid.beta2/uuid.info uuid/uuid.info
--- uuid.beta2/uuid.info	2010-09-08 12:21:50.000000000 -0400
+++ uuid/uuid.info	2010-09-08 20:23:34.000000000 -0400
@@ -3,9 +3,9 @@ name = "Universally Unique IDentifier (U
 description = "Generate Universally Unique IDentifier (UUID) for content."
 core = 6.x
 
-; Information added by drupal.org packaging script on 2010-09-08
-version = "6.x-1.0-beta2"
+; Information added by drupal.org packaging script on 2010-09-09
+version = "6.x-1.x-dev"
 core = "6.x"
 project = "uuid"
-datestamp = "1283962910"
+datestamp = "1283991814"
 
diff -urp uuid.beta2/uuid.install uuid/uuid.install
--- uuid.beta2/uuid.install	2010-09-08 12:07:14.000000000 -0400
+++ uuid/uuid.install	2010-09-21 21:29:02.000000000 -0400
@@ -11,6 +11,7 @@
  */
 function uuid_enable() {
   module_load_include('inc', 'uuid', 'uuid.admin');
+  uuid_init_namespace();
   uuid_sync();
 }
 
@@ -28,7 +29,7 @@ function uuid_install() {
 function uuid_schema() {
   return array(
     'uuid_node' => uuid_table_schema('node', 'nid'),
-    'uuid_node_revisions' => uuid_table_schema('node_revisions', 'vid'),
+    'uuid_node_revisions' => uuid_node_revisions_table_schema('vid'),
     'uuid_users' => uuid_table_schema('users', 'uid'),
     'uuid_vocabulary' => uuid_table_schema('vocabulary', 'vid'),
     'uuid_term_data' => uuid_table_schema('term_data', 'tid'),
@@ -56,7 +57,7 @@ function uuid_table_schema($table, $key 
         'description' => 'The primary key of the record which this UUID was generated for.',
       ),
       'uuid' => array(
-        'type' => 'varchar',
+        'type' => 'char',
         'length' => 64,
         'not null' => TRUE,
         'default' => '',
@@ -71,6 +72,35 @@ function uuid_table_schema($table, $key 
 }
 
 /**
+ * Return schema for the uuid node revision table.
+ *
+ * @param $key
+ *   Name of key field, e.g. nid for nodes.
+ *
+ * @return
+ *   Array with table structure definition (schema).
+ */
+function uuid_node_revisions_table_schema($key = 'key') {
+	// get the standard schema
+	$schema = uuid_table_schema('uuid_node_revisions', $key);
+	
+	// add the node id column
+	if (is_array($schema) && isset($schema['fields'])) {
+		// no index needed on this column as it will only 
+		// be used during a node delete.
+		$schema['fields']['nid'] = array(
+			'type' => 'int',
+			'length' => 10,
+			'unsigned' => TRUE,
+			'not null' => TRUE,
+			'default' => 0,
+			'description' => 'The revision\'s node id. Needed for delete node operations.',
+		);
+	}
+	return $schema;
+}
+
+/**
  * Implementation of hook_uninstall().
  */
 function uuid_uninstall() {
@@ -78,11 +108,19 @@ function uuid_uninstall() {
   variable_del('uuid_automatic_for_users');
   variable_del('uuid_automatic_for_taxonomy');
   variable_del('uuid_automatic_for_comments');
+  variable_del('uuid_version');
+  variable_del('uuid_namespace');
 
   // Remove tables.
   drupal_uninstall_schema('uuid');
 }
 
+function uuid_init_namespace() {
+	if (!variable_get('uuid_namespace', '')) {
+		variable_set('uuid_namespace', uuid_uuid());
+	}
+}
+
 /**
  * Create uuid_vocabulary and uuid_term_data tables.
  */
@@ -111,12 +149,52 @@ function uuid_update_6002() {
 }
 
 /**
- * Create uuid_comment table.
+ * 1. Create uuid_comment table.
+ * 
+ * 2. fix the column definitions for uuid columns in all tables
+ * to use the more efficient char spec.
  */
 function uuid_update_6003() {
   $ret = array();
 
-  db_create_table($ret, 'uuid_comments', uuid_table_schema('comments', 'cid'));
+	if (!db_table_exists('uuid_comments')) {
+	  db_create_table($ret, 'uuid_comments', uuid_table_schema('comments', 'cid'));
+  }
+
+	$tables = uuid_schema();//
+	$tables = array_keys($tables);
+	// use what's in uuid_table_schema in order to be consistent
+	$field_specs = uuid_table_schema('uuid_node');
+	$spec = $field_specs['fields']['uuid'];
+
+	while(list(,$table) = each($tables)) {
+		if (db_table_exists($table)) {
+		  db_change_field($ret, $table, 'uuid', 'uuid', $spec);
+		}
+	}
+
+	if (db_table_exists('uuid_node_revisions')) {
+		// use what's in uuid_table_schema in order to be consistent
+		$field_specs = uuid_node_revisions_table_schema('vid');
+		$spec = $field_specs['fields']['nid'];
+		db_add_field($ret, 'uuid_node_revisions', 'nid', $spec);
+		//add node ids to the new column, for revisions that exist, but now
+		//have default value of 0 in uuid_node_revisions
+		$result = db_query('SELECT nr.nid, nr.vid FROM {node_revisions} AS nr	LEFT JOIN {uuid_node_revisions} AS unr ON unr.vid=nr.vid WHERE unr.nid=%d', 0);
+    while ($item = db_fetch_object($result)) {
+      $ret[] = update_sql('UPDATE {uuid_node_revisions} SET nid='.(int) $item->nid .' WHERE vid='. (int) $item->vid);
+    }
+		//add uuid_node_revision rows for rows that don't exist, but should
+		$result = db_query('SELECT nr.nid, nr.vid FROM {node_revisions} AS nr	LEFT JOIN {uuid_node_revisions} AS unr ON unr.vid=nr.vid WHERE unr.nid IS NULL');
+    while ($item = db_fetch_object($result)) {
+      $ret[] = update_sql(sprintf("INSERT INTO {uuid_node_revisions} (vid, uuid, nid) VALUES(%d, '%s', %d)", $item->vid, uuid_uuid(), $item->nid));
+    }
+    // Delete any orphaned revision vid, uuid pairs.
+    $ret[] = update_sql('DELETE FROM {uuid_node_revisions} WHERE nid=0');
+	}
+	
+	// Set up the initial UUID namespace for the site.
+	uuid_init_namespace();
 
   return $ret;
 }
diff -urp uuid.beta2/uuid.module uuid/uuid.module
--- uuid.beta2/uuid.module	2010-09-08 12:07:14.000000000 -0400
+++ uuid/uuid.module	2010-09-21 18:49:44.000000000 -0400
@@ -5,6 +5,7 @@
  * @file
  * Main module functions for the uuid module.
  */
+define('UUID_VERSION_DEFAULT', 'v4');
 
 /**
  * Implementation of hook_menu().
@@ -33,10 +34,18 @@ function uuid_nodeapi(&$node, $op, $teas
 
   switch ($op) {
     case 'load':
-      return array(
-        'uuid' => db_result(db_query('SELECT uuid FROM {uuid_node} WHERE nid = %d', $node->nid)),
-        'revision_uuid' => db_result(db_query('SELECT uuid FROM {uuid_node_revisions} WHERE vid = %d', $node->vid))
-      );
+			/**
+			 * Rewrote this into one query. Each separate query
+			 * takes 8.9ms = 18.8ms. A join takes 9.1ms, so we save
+			 * 50% over the previous 2 query code. On nodeapi 'load'
+			 * that can add up a lot in a long node list.
+			 */
+			if ($arr = db_fetch_array(db_query('SELECT un.uuid AS uuid, unr.uuid AS revision_uuid FROM {uuid_node} un LEFT JOIN {uuid_node_revisions} unr ON unr.vid=%d WHERE un.nid=%d', $node->vid, $node->nid))) {
+				return $arr;
+			}
+			else {
+				return array('uuid'=>FALSE, 'revision_uuid'=>FALSE);
+			}
     case 'insert':
       // Handle the case where automatic UUID generation is turned OFF but a
       // node is created, node_save(), intentionally with the $node->uuid
@@ -45,29 +54,36 @@ function uuid_nodeapi(&$node, $op, $teas
         db_query("INSERT INTO {uuid_node} (nid, uuid) VALUES (%d, '%s')", $node->nid, $node->uuid);
 
         if (isset($node->revision_uuid) && uuid_is_valid($node->revision_uuid)) {
-          db_query("INSERT INTO {uuid_node_revisions} (vid, uuid) VALUES (%d, '%s')", $node->vid, $node->revision_uuid);
+          db_query("INSERT INTO {uuid_node_revisions} (vid, uuid, nid) VALUES (%d, '%s', %d)", $node->vid, $node->revision_uuid, $node->nid);
         }
         else {
-          db_query("INSERT INTO {uuid_node_revisions} (vid, uuid) VALUES (%d, '%s')", $node->vid, uuid_uuid());
+					//attach new revision uuid to node, don't just insert
+					$node->revision_uuid = uuid_uuid();
+          db_query("INSERT INTO {uuid_node_revisions} (vid, uuid, nid) VALUES (%d, '%s', %d)", $node->vid, $node->revision_uuid, $node->nid);
         }
       }
       else if (in_array($node->type, $automatic_types)) {
         db_query("INSERT INTO {uuid_node} (nid, uuid) VALUES (%d, '%s')", $node->nid, uuid_uuid());
-        db_query("INSERT INTO {uuid_node_revisions} (vid, uuid) VALUES (%d, '%s')", $node->vid, uuid_uuid());
+				//attach new revision uuid to node, don't just insert
+				$node->revision_uuid = uuid_uuid();
+        db_query("INSERT INTO {uuid_node_revisions} (vid, uuid, nid) VALUES (%d, '%s', %d)", $node->vid, $node->revision_uuid, $node->nid);
       }
       break;
     case 'update':
-      if (isset($node->revision)) {
-        if (isset($node->revision_uuid) && uuid_is_valid($node->revision_uuid)) {
-          db_query("INSERT INTO {uuid_node_revisions} (vid, uuid) VALUES (%d, '%s')", $node->vid, $node->revision_uuid);
-        }
-        else {
-          db_query("INSERT INTO {uuid_node_revisions} (vid, uuid) VALUES (%d, '%s')", $node->vid, uuid_uuid());
+			if (isset($node->revision)) {
+				db_query("DELETE FROM {uuid_node_revisions} WHERE vid=%d", $node->vid);
+
+        if (!isset($node->revision_uuid) || !uuid_is_valid($node->revision_uuid)) {
+					$node->revision_uuid = uuid_uuid();
         }
+
+        db_query("INSERT INTO {uuid_node_revisions} (vid, uuid, nid) VALUES (%d, '%s', %d)", $node->vid, $node->revision_uuid, $node->nid);
       }
       break;
     case 'delete':
       db_query('DELETE FROM {uuid_node} WHERE nid = %d', $node->nid);
+      //delete the revision uuids for the node.
+      db_query('DELETE FROM {uuid_node_revisions} WHERE nid = %d', $node->nid);
       break;
     case 'delete revision':
       db_query('DELETE FROM {uuid_node_revisions} WHERE vid = %d', $node->vid);
@@ -102,17 +118,34 @@ function node_get_by_uuid($uuid) {
 /**
  * Returns the node associated with a revision UUID.
  *
+ * @todo One thing to ascertain here is whether this function
+ * should only return the node if the revision's uuid is the
+ * active revision for that node, or if it should also return
+ * the node even if the revision is not the active one. We 
+ * make this the default implementation for now, just to be on
+ * the safe side.
+ *
+ * @param string $revision_uuid The uuid to use for the node
+ * lookup
+ * @param bool $active_only Should a node only be returned if
+ * the passed revision uuid is the currently active one for
+ * the node? Default: TRUE
  * @return
  *   Either the $node object, or FALSE on failure.
  */
-function node_get_by_revision_uuid($revision_uuid) {
-  $node = db_fetch_object(db_query(db_rewrite_sql(
-    "SELECT n.nid, n.vid
-     FROM {node} AS n
-     INNER JOIN {uuid_node_revisions} AS unr ON n.vid = unr.vid
-     WHERE unr.uuid = '%s'"),
-    $revision_uuid
-  ));
+function node_get_by_revision_uuid($revision_uuid, $active_only=TRUE) {
+	if ($active_only) {
+	  $node = db_fetch_object(db_query(db_rewrite_sql(
+			"SELECT n.nid, n.vid
+			 FROM {node} AS n
+			 INNER JOIN {uuid_node_revisions} AS unr ON n.vid = unr.vid
+			 WHERE unr.uuid = '%s'"),
+			$revision_uuid
+		));
+	}
+	else {
+	  $node = db_fetch_object(db_query("SELECT nid, vid FROM {uuid_node_revisions} WHERE uuid = '%s'", $revision_uuid));
+	}
 
   if ($node->nid && $node->vid) {
     return node_load($node->nid, $node->vid);
@@ -237,6 +270,10 @@ function uuid_comment(&$a1, $op) {
 
 /**
  * Determines if a UUID is valid.
+ *
+ * @todo use is_valid() method in uuid class. Leave as is in
+ * order to not break poorly formatted previously generated
+ * uuids.
  */
 function uuid_is_valid($uuid) {
   return (boolean) preg_match('/^[A-Fa-f0-9]{8}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{12}$/', $uuid);
@@ -247,35 +284,41 @@ function uuid_is_valid($uuid) {
  *
  * @see http://www.ietf.org/rfc/rfc4122.txt
  * @see http://php.net/manual/en/function.uniqid.php#65879
+ * @see http://php.net/manual/en/function.uniqid.php#94959
+ *
+ * @param string $uuid_version The version of the uuid to be
+ * generated.
  *
  * @return
  *   An UUID, made up of 32 hex digits and 4 hyphens.
  */
-function uuid_uuid() {
-  // If we're not using postgres, the database will give us a UUID.
-  if ($GLOBALS['db_type'] != 'pgsql') {
-    return db_result(db_query('SELECT UUID()'));
-  }
-
-  // If the function provided by the uuid pecl extension is available, use that.
-  if(function_exists('uuid_create')) {
-    return uuid_create(UUID_TYPE_DEFAULT);
-  }
-
-  // Fall back to generating a Universally Unique IDentifier version 4.
-  // Base on http://php.net/manual/en/function.uniqid.php#65879
-  // The field names refer to RFC 4122 section 4.1.2.
-  return sprintf('%04x%04x-%04x-%03x4-%04x-%04x%04x%04x',
-    // 32 bits for "time_low".
-    mt_rand(0, 65535), mt_rand(0, 65535),
-    // 16 bits for "time_mid".
-    mt_rand(0, 65535),
-    // 12 bits before the 0100 of (version) 4 for "time_hi_and_version".
-    mt_rand(0, 4095),
-    bindec(substr_replace(sprintf('%016b', mt_rand(0, 65535)), '01', 6, 2)),
-    // 8 bits, the last two of which (positions 6 and 7) are 01, for "clk_seq_hi_res"
-    // (hence, the 2nd hex digit after the 3rd hyphen can only be 1, 5, 9 or d)
-    // 8 bits for "clk_seq_low" 48 bits for "node".
-    mt_rand(0, 65535), mt_rand(0, 65535), mt_rand(0, 65535)
-  );
+function uuid_uuid($uuid_version='') {
+	//static so fewer system calls via php_uname()
+	static $prefix = '';
+  if (empty($uuid_version)) {
+  	$uuid_version = variable_get('uuid_version', UUID_VERSION_DEFAULT);
+  }
+
+  module_load_include('inc', 'uuid', 'uuid.class');
+  
+  switch($uuid_version) {
+  	case 'v3':
+  	case 'v5':
+  		//in the off-chance there is no namespace set, fallback
+  		//to v4 namespace
+  		$namespace = variable_get('uuid_namespace', uuid::v4());
+  		if (empty($prefix)) {
+  			$prefix = @php_uname('n');
+  		}
+  		$uuid = uuid::$uuid_version($namespace, uniqid($prefix, TRUE));
+  		break;
+  	case 'v4':
+  		$uuid = uuid::v4();
+  		break;
+  	default:
+  		$uuid = uuid_uuid(UUID_VERSION_DEFAULT);
+  		break;
+  }
+  
+  return $uuid;
 }
