diff --git a/mollom.module b/mollom.module
index ebb1e13..d0de4da 100644
--- a/mollom.module
+++ b/mollom.module
@@ -1103,26 +1103,46 @@ function mollom_form_get_values($form_values, $fields, $mapping) {
     $data['post_body'] = $post_body;
   }
 
+  // User ID.
+  if (!empty($mapping['author_id'])) {
+    $data['author_id'] = $mapping['author_id'];
+  }
+  elseif ($user->uid) {
+    $data['author_id'] = $user->uid;
+  }
+  if (isset($data['author_id'])) {
+    $account = user_load(array('uid' => $data['author_id']));
+  }
+
   // User name.
+  // A form value mapping always has precedence.
   if (!empty($mapping['author_name'])) {
     $data['author_name'] = $mapping['author_name'];
-    // Try to inherit user from author name.
-    $account = user_load(array('name' => $data['author_name']));
   }
-  elseif (!empty($user->name)) {
+  // In case a post of a registered user is edited and a form value mapping
+  // exists for author_id, but no form value mapping exists for author_name,
+  // use the name of the user account associated with author_id.
+  elseif (!empty($account->name)) {
+    $data['author_name'] = $account->name;
+  }
+  // Otherwise, use information of currently logged in user.
+  elseif ($user->uid) {
     $data['author_name'] = $user->name;
   }
 
   // User e-mail.
+  // A form value mapping always has precedence.
   if (!empty($mapping['author_mail'])) {
     $data['author_mail'] = $mapping['author_mail'];
   }
-  elseif (!empty($data['author_name'])) {
-    if (!empty($account->mail)) {
-      $data['author_mail'] = $account->mail;
-    }
+  // In case a post of a registered user is edited and a form value mapping
+  // exists for author_id, but no form value mapping exists for author_mail,
+  // use the name of the user account associated with author_id.
+  elseif (!empty($account->mail)) {
+    $data['author_mail'] = $account->mail;
   }
-  elseif (!empty($user->mail)) {
+  // Otherwise, use information of currently logged in user.
+  elseif ($user->uid && !empty($user->mail)) {
     $data['author_mail'] = $user->mail;
   }
 
@@ -1131,29 +1151,18 @@ function mollom_form_get_values($form_values, $fields, $mapping) {
     $data['author_url'] = $mapping['author_url'];
   }
 
-  // User ID.
-  if (!empty($mapping['author_id'])) {
-    $data['author_id'] = $mapping['author_id'];
-  }
-  elseif (!empty($data['author_name'])) {
-    if (!empty($account->uid)) {
-      $data['author_id'] = $account->uid;
-    }
-  }
-  elseif (!empty($user->uid)) {
-    $data['author_id'] = $user->uid;
-  }
-
   // User OpenID.
+  // A form value mapping always has precedence.
   if (!empty($mapping['author_openid'])) {
     $data['author_openid'] = $mapping['author_openid'];
   }
-  elseif (!empty($data['author_id'])) {
-    if (!empty($account->uid) && ($openid = _mollom_get_openid($account))) {
-      $data['author_openid'] = $openid;
-    }
+  // In case a post of a registered user is edited and a form value mapping
+  // exists for author_id, but no form value mapping exists for author_openid,
+  // use the name of the user account associated with author_id.
+  elseif (!empty($account->uid) && ($openid = _mollom_get_openid($account))) {
+    $data['author_openid'] = $openid;
   }
-  elseif (!empty($user->uid) && ($openid = _mollom_get_openid($user))) {
+  elseif ($user->uid && ($openid = _mollom_get_openid($user))) {
     $data['author_openid'] = $openid;
   }
 
@@ -1209,11 +1218,11 @@ function _mollom_flatten_form_values(&$values) {
  */
 function _mollom_get_openid($account) {
   if (isset($account->uid)) {
-    $result = db_query("SELECT * FROM {authmap} WHERE module = 'openid' AND uid = %d", $account->uid);
+    $result = db_query("SELECT authname FROM {authmap} WHERE module = 'openid' AND uid = %d", $account->uid);
 
     $ids = array();
-    while ($identity = db_fetch_object($result)) {
-      $ids[] = $identity->authname;
+    while ($authname = db_result($result)) {
+      $ids[] = $authname;
     }
 
     if (!empty($ids)) {
