Index: comment_notify/comment_notify.install
===================================================================
--- comment_notify/comment_notify.install	(revision 22483)
+++ comment_notify/comment_notify.install	(working copy)
@@ -122,3 +122,10 @@
   db_drop_index('comment_notify', 'notify_hash');
   db_change_field('comment_notify', 'notify_hash', 'notify_hash', $new_spec, $keys);
 }
\ No newline at end of file
+
+/**
+ * Remove notification settings for deleted users.
+ */
+function comment_notify_update_7003() {
+  db_query ('delete from {comment_notify_user_settings} where uid not in (select uid from {users})');
+}
\ No newline at end of file
Index: comment_notify/comment_notify.inc
===================================================================
--- comment_notify/comment_notify.inc	(revision 22483)
+++ comment_notify/comment_notify.inc	(working copy)
@@ -23,7 +23,7 @@
     // Handle anonymous users with defaults.
     if ($uid == 0) {
       $users[0] = new stdClass();
-      $users[0]->comment_notify = comment_notify_variable_registry_get('default_registered_mailalert');
+      $users[0]->comment_notify = comment_notify_variable_registry_get('default_anon_mailalert');
       $users[0]->node_notify = comment_notify_variable_registry_get('node_notify_default_mailalert');
     }
     else {
Index: comment_notify/comment_notify.module
===================================================================
--- comment_notify/comment_notify.module	(revision 22487)
+++ comment_notify/comment_notify.module	(working copy)
@@ -299,12 +299,12 @@
   if (!($form_id == 'user_register_form' || $form_id == 'user_profile_form')) {
     return;
   }
-  elseif ($form['#user_category'] != 'account') {
+  elseif ($form['#user_category'] != 'account' && $form['#user_category'] != 'register') {
     return;
   }
 
   $user = $form['#user'];
-  if ($user->comment_notify_settings) {
+  if (isset ($user->comment_notify_settings)) {
     $node_notify = $user->comment_notify_settings->node_notify;
     $comment_notify = $user->comment_notify_settings->comment_notify;
   }
@@ -345,7 +345,7 @@
   $form['comment_notify_settings']['comment_notify'] = array(
     '#type' => 'select',
     '#title' => t('Receive comment follow-up notification e-mails'),
-    '#default_value' => isset($comment_notify) ? array($comment_notify) : array(comment_notify_variable_registry_get('comment_notify_default_registered_mailalert')),
+    '#default_value' => isset($comment_notify) ? array($comment_notify) : array(comment_notify_variable_registry_get('default_registered_mailalert')),
     '#options' => $available_options,
     '#description' => t("Check this box to receive e-mail notification for follow-up comments to comments you posted. You can later disable this on a post-by-post basis... so if you leave this to YES, you can still disable follow-up notifications for comments you don't want follow-up mails anymore - i.e. for very popular posts.")
   );
@@ -353,6 +353,22 @@
   // Construct the user form
 }
 
+function comment_notify_user_insert(&$edit, $account, $category) {
+  if ($category != 'account') {
+    return;
+  }
+  if (isset($edit['node_notify']) && isset($edit['comment_notify'])) {
+    module_load_include('inc', 'comment_notify', 'comment_notify');
+
+    // Save the values of node_notify_mailalert and comment_notify_mailalert
+    // to {comment_notify_user_settings}.
+    comment_notify_set_user_notification_setting($account->uid, $edit['node_notify'], $edit['comment_notify']);
+  }
+  // Unset them from $user so they don't also get saved into {users}.data.
+  unset($edit['node_notify']);
+  unset($edit['comment_notify']);
+}
+
 function comment_notify_user_update(&$edit, $account, $category) {
   if ($category != 'account') {
     return;
@@ -367,7 +383,10 @@
   // Unset them from $user so they don't also get saved into {users}.data.
   unset($edit['node_notify']);
   unset($edit['comment_notify']);
+}
 
+function comment_notify_user_delete($account) {
+  db_delete('comment_notify_user_settings')->condition('uid', $account->uid)->execute();
 }
 
 function comment_notify_user_load($users) {
