diff --git a/support.module b/support.module
index 057a2a6..d16a8c2 100755
--- a/support.module
+++ b/support.module
@@ -118,7 +118,7 @@ function support_menu() {
       'access arguments' => array('download mail via support/fetch'),
   );
 
-  // Autocomplete paths
+// Autocomplete paths
   $items['support/autocomplete/assigned'] = array(
       'title' => 'Autocomplete support assigned user',
       'page callback' => 'support_autocomplete_assigned',
@@ -263,7 +263,7 @@ function support_init() {
   global $conf;
 
   if (module_exists('i18n')) {
-    // Make all mail text variables translatable.
+// Make all mail text variables translatable.
     foreach (_support_mail_text_default(NULL) as $key => $text) {
       $conf['i18n_variables'][] = 'support_mail_' . $key;
     }
@@ -278,16 +278,16 @@ function support_autocomplete_assigned($clid = 0, $string = '') {
   if ($string) {
     if ($clid) {
       $client = db_query('SELECT name FROM {support_client} WHERE clid = :clid', array(':clid' => $clid))->fetchField();
-      // retrieve all roles giving permission to access current tickets
-      // TODO Please convert this statement to the D7 database API syntax.
+// retrieve all roles giving permission to access current tickets
+// TODO Please convert this statement to the D7 database API syntax.
       $result = db_query("SELECT rid FROM {role_permission} WHERE permission LIKE :clike OR permission LIKE :plike", array(':clike' => '%' . $client . '%', ':plike' => '%administer support%'));
     }
     $roles = array();
     foreach ($result as $role) {
       $roles[$role->rid] = $role->rid;
     }
-    // also get people with administer support permissions
-    // TODO Please convert this statement to the D7 database API syntax.
+// also get people with administer support permissions
+// TODO Please convert this statement to the D7 database API syntax.
     $result = db_query("SELECT rid FROM {role_permission} WHERE permission LIKE :plike", array(':plike' => '%administer support%'));
     foreach ($result as $role) {
       $roles[$role->rid] = $role->rid;
@@ -307,11 +307,11 @@ function support_autocomplete_assigned($clid = 0, $string = '') {
  * Autocomplete usernames to assign to ticket.
  */
 function support_autocomplete_autosubscribe($clid, $string = '') {
-  // The user enters a comma-separated list of users.  We only autocomplete the
-  // last user.
+// The user enters a comma-separated list of users.  We only autocomplete the
+// last user.
   $array = drupal_explode_tags($string);
 
-  // Fetch last user.
+// Fetch last user.
   $last_string = trim(array_pop($array));
 
   $matches = array();
@@ -320,8 +320,8 @@ function support_autocomplete_autosubscribe($clid, $string = '') {
     $client = db_query('SELECT name FROM {
         support_client
       } WHERE clid = :clid', array(':clid' => $clid))->fetchField();
-    // retrieve all roles giving permission to access current tickets
-    // TODO Please convert this statement to the D7 database API syntax.
+// retrieve all roles giving permission to access current tickets
+// TODO Please convert this statement to the D7 database API syntax.
     $result = db_query("SELECT rid FROM {role_permission} WHERE permission LIKE :clike OR perm LIKE :plike", array(':clike' => '%' . $client . '%', ':plike' => '%administer support%'));
     foreach ($result as $role) {
       $roles[$role->rid] = $role->rid;
@@ -409,11 +409,11 @@ function support_active_clients() {
  * Unsubscribe user from tickets.
  */
 function support_unsubscribe_user($node, $account, $key) {
-  // unsubscribe from a single node
+// unsubscribe from a single node
   if (is_object($node) && is_object($account)) {
     $lock = md5($account->uid . $node->nid);
     if ($key == $lock) {
-      // TODO Please review the conversion of this statement to the D7 database API syntax.
+// TODO Please review the conversion of this statement to the D7 database API syntax.
       /* db_query('UPDATE {
         support_assigned
         } SET active = 0 WHERE uid = %d AND nid = %d', $account->uid, $node->nid) */
@@ -432,7 +432,7 @@ function support_unsubscribe_user($node, $account, $key) {
   } else if (is_object($account)) {
     $lock = md5($account->uid);
     if ($key == $lock) {
-      // TODO Please review the conversion of this statement to the D7 database API syntax.
+// TODO Please review the conversion of this statement to the D7 database API syntax.
       /* db_query('UPDATE {
         support_assigned
         } SET active = 0 WHERE uid = %d', $account->uid) */
@@ -539,19 +539,19 @@ function _support_domains($client, $global) {
 function support_account_load($from, $ticket, $subject, $client) {
   $uid = db_query("SELECT uid FROM {users} WHERE mail = :mail", array(':mail' => $from))->fetchField();
   if ($uid) {
-    // TODO Convert "user_load" to "user_load_multiple" if "$uid" is other than a uid.
-    // To return a single user object, wrap "user_load_multiple" with "array_shift" or equivalent.
-    // Example: array_shift(user_load_multiple(array(), $uid))
+// TODO Convert "user_load" to "user_load_multiple" if "$uid" is other than a uid.
+// To return a single user object, wrap "user_load_multiple" with "array_shift" or equivalent.
+// Example: array_shift(user_load_multiple(array(), $uid))
     return user_load($uid);
   } else if ($client->user_creation == 2 ||
           ($client->user_creation == 0 && variable_get('support_autocreate_users', TRUE) == FALSE)) {
-    // User does not exist and the setting to allow automatic creation is
-    // disabled.  Send notification to user.
+// User does not exist and the setting to allow automatic creation is
+// disabled.  Send notification to user.
     watchdog('support', 'An autocreation of a user from the e-mail address: !from was denied. The client recieving the request was: !client', array('!from' => utf8_encode($from), '!client' => $client->name));
     _support_mail_deny($from);
     return FALSE;
   } else {
-    // extract the domain out of the from email address
+// extract the domain out of the from email address
     $matches = array();
     preg_match('~[\w-]+\.\w+(?=/|$)~', $from, $matches);
     $domain = $matches[0];
@@ -567,11 +567,11 @@ function support_account_load($from, $ticket, $subject, $client) {
         }
       }
     }
-    // TODO: this isn't a role, this is a permission
-    //$role = "access $client->name tickets";
+// TODO: this isn't a role, this is a permission
+//$role = "access $client->name tickets";
     if ($valid) {
       watchdog('support', 'User !username automatically created.', array('!username' => $from), WATCHDOG_NOTICE);
-      //return user_save(NULL, array('mail' => $from, 'init' => $from, 'name' => $from, 'status' => 1, 'roles' => array($role)));
+//return user_save(NULL, array('mail' => $from, 'init' => $from, 'name' => $from, 'status' => 1, 'roles' => array($role)));
       return user_save(NULL, array('mail' => $from, 'init' => $from, 'name' => $from, 'status' => 1));
     } else {
       $node = node_load($ticket->nid);
@@ -731,7 +731,7 @@ function support_form($node, $form_state) {
 function support_node_view($node, $view_mode, $langcode) {
   global $user;
   if ($node->type == 'support_ticket') {
-    // viewing a ticket
+// viewing a ticket
     drupal_add_css(drupal_get_path('module', 'support') . '/support-tickets.css');
     $breadcrumb = array();
     $breadcrumb[] = l(t('Home'), NULL);
@@ -793,7 +793,7 @@ function support_node_validate($node, $form, &$form_state) {
         form_set_error('move', t('Destination node does not exist.'));
       }
     }
-    // check for users subscribed during ticket creation (checkboxes)
+// check for users subscribed during ticket creation (checkboxes)
     if (isset($node->notifications) && !empty($node->notifications)) {
       $notifications = explode(',', $node->notifications);
       foreach ($notifications as $notify) {
@@ -804,7 +804,7 @@ function support_node_validate($node, $form, &$form_state) {
         }
       }
     }
-    // check for users subscribed during ticket creation (autocomplete)
+// check for users subscribed during ticket creation (autocomplete)
     else if (!empty($node->$autocomplete)) {
       $notifications = explode(',', $node->$autocomplete);
       foreach ($notifications as $notify) {
@@ -833,7 +833,7 @@ function _support_node_insert_update($node) {
       $node->assigned = 0;
     }
   }
-  // TODO Please review the conversion of this statement to the D7 database API syntax.
+// TODO Please review the conversion of this statement to the D7 database API syntax.
   /* db_query("UPDATE {support_ticket} SET message_id = '%s', state = %d, priority = %d, client = %d, assigned = %d WHERE nid = %d", isset($node->message_id) ? $node->message_id : '', $node->state, $node->priority, $node->client, $node->assigned, $node->nid) */
   $update = db_update('support_ticket')
           ->fields(array(
@@ -882,23 +882,23 @@ function support_node_insert($node) {
   if ($node->type == 'support_ticket') {
     _support_node_insert_update($node);
 
-    // auto-subscribe ticket creator
+// auto-subscribe ticket creator
     if (variable_get('support_autosubscribe_creator', FALSE) || isset($node->created_by_email)) {
       support_subscribe_user($node->nid, $node->uid);
     } else {
       support_subscribe_user($node->nid, $node->uid, $node->notification);
     }
-    // auto-subscribe assigned user
+// auto-subscribe assigned user
     if ($node->assigned || isset($node->created_by_email) || !user_access('can subscribe other users to notifications')) {
       support_subscribe_user($node->nid, $node->assigned);
     }
-    // auto-subscribe configured users
+// auto-subscribe configured users
     if (variable_get('support_autosubscribe_force', FALSE) ||
             isset($node->created_by_email) ||
             !user_access('can subscribe other users to notifications')) {
       _support_autosubscribe($node->nid, $node->client);
     }
-    // generate notification emails
+// generate notification emails
     support_notification(array(), $node->nid, 'ticket_new', isset($node->suppress) ? $node->suppress : FALSE);
 
     cache_clear_all();
@@ -920,7 +920,7 @@ function support_node_update($node) {
  */
 function support_node_delete($node) {
   if ($node->type == 'support_ticket') {
-    // TODO Please review the conversion of this statement to the D7 database API syntax.
+// TODO Please review the conversion of this statement to the D7 database API syntax.
     /* db_query('DELETE FROM {support_ticket} WHERE nid = %d', $node->nid) */
     db_delete('support_ticket')
             ->condition('nid', $node->nid)
@@ -937,7 +937,7 @@ function _support_comment_insert_update($comment) {
       $comment->assigned = 0;
     }
   }
-  // TODO Please review the conversion of this statement to the D7 database API syntax.
+// TODO Please review the conversion of this statement to the D7 database API syntax.
   /* db_query("UPDATE {support_ticket_comment} SET message_id = '%s', state = %d, priority = %d, client = %d, assigned = %d WHERE cid = %d", isset($comment['message_id']) ? $comment['message_id'] : '', $comment['state'], $comment['priority'], $comment['client'], $comment['assigned'], $comment['cid']) */
   $update = db_update('support_ticket_comment')
           ->fields(array(
@@ -960,9 +960,9 @@ function _support_comment_insert_update($comment) {
                 'assigned' => $comment->assigned
             ))
             ->execute();
-    // The first update to a ticket is not preserved in the database.
-    // Store it in an array allowing other modules to dectect/respond to
-    // ticket changes.
+// The first update to a ticket is not preserved in the database.
+// Store it in an array allowing other modules to dectect/respond to
+// ticket changes.
     $comment->previous = new stdClass();
     $comment->previous->state = $comment->state;
     $comment->previous->priority = $comment->priority;
@@ -973,7 +973,7 @@ function _support_comment_insert_update($comment) {
 }
 
 function _support_comment_insert_update2($comment) {
-  // if admin, can update who is assigned to the ticket
+// if admin, can update who is assigned to the ticket
   if (user_access('administer support') && (!isset($comment->support_email) || !$comment->support_email)) {
     if (isset($comment->subscribed_users) && !empty($comment->subscribed_users)) {
       $array = drupal_explode_tags($comment->subscribed_users);
@@ -1006,21 +1006,21 @@ function support_comment_insert($comment) {
   if ($node->type == 'support_ticket') {
     _support_comment_insert_update($comment);
 
-    // auto-subscribe ticket-comment creator
+// auto-subscribe ticket-comment creator
     if (variable_get('support_autosubscribe_creator', FALSE)) {
       support_subscribe_user($comment->nid, $comment->uid);
     } else {
       support_subscribe_user($comment->nid, $comment->uid, $comment->notification);
     }
-    // force auto-subscribe configured users
+// force auto-subscribe configured users
     if (variable_get('support_autosubscribe_force', FALSE)) {
       _support_autosubscribe($comment->nid, $comment->client);
     }
-    // auto-subscribe assigned user
+// auto-subscribe assigned user
     if ($comment->assigned) {
       support_subscribe_user($comment->nid, $comment->assigned);
     }
-    // generate notification emails
+// generate notification emails
     support_notification($comment, $comment->nid, 'ticket_comment_new', isset($comment->suppress) ? $comment->suppress : FALSE);
 
     _support_comment_insert_update2($comment);
@@ -1052,7 +1052,7 @@ function support_comment_delete($comment) {
     $node = node_load($comment->nid);
   }
   if ($node->type == 'support_ticket') {
-    // TODO Please review the conversion of this statement to the D7 database API syntax.
+// TODO Please review the conversion of this statement to the D7 database API syntax.
     /* db_query('DELETE FROM {support_ticket_comment} WHERE cid = %d', $comment->cid) */
     db_delete('support_ticket_comment')
             ->condition('cid', $comment->cid)
@@ -1144,30 +1144,30 @@ function support_mail($key, &$message, $params) {
   $language = $message['language'];
   $variables = support_mail_tokens($params['account'], $language, $params['nid'], (isset($params['comment']) ? $params['comment'] : array()), $params['suppress']);
   $message['subject'] .= _support_mail_text($key . '_subject', $language, $variables, $params['integrate_email']);
-  $message['body'] = _support_mail_text($key . '_body', $language, $variables, $params['integrate_email']);
+  $message['body'] = array(_support_mail_text($key . '_body', $language, $variables, $params['integrate_email']));
   $node = node_load($params['nid']);
   $client = support_client_load($node->client);
   if ($client->integrate_email) {
-    // Add a string allowing the support module to try and strip previously
-    // quoted ticket notifications from emailed replies.
+// Add a string allowing the support module to try and strip previously
+// quoted ticket notifications from emailed replies.
     $array = explode("\n", $message['body']);
     $length = sizeof($array);
     $md5 = md5($length);
     $message['body'] .= "\n\n[$length:$md5]\n";
   }
 
-  // We generate message ids based on comment cids and support nids.
-  // This allows readers to properly thread the messages coming from us,
-  // as well as allow us to detect what comment an incoming email is a reply to,
-  // so we can (optionally) handle threaded comments.
+// We generate message ids based on comment cids and support nids.
+// This allows readers to properly thread the messages coming from us,
+// as well as allow us to detect what comment an incoming email is a reply to,
+// so we can (optionally) handle threaded comments.
   $cid = $params['cid'];
   $references = array();
   while ($cid) {
     $cid = db_query('SELECT pid FROM {comment} WHERE cid = :cid', array(':cid' => $cid))->fetchField();
-    // The last one will be cid 0.
+// The last one will be cid 0.
     $references[] = _support_generate_message_id($params['nid'], $cid);
   }
-  // Set up message id and threading.
+// Set up message id and threading.
   $message['headers']['Message-Id'] = _support_generate_message_id($params['nid'], $params['cid']);
   if (!empty($references)) {
     $message['headers']['In-Reply-To'] = $references[0];
@@ -1194,14 +1194,14 @@ function _support_node_move($node, $destination) {
     drupal_set_message('Permission denied, unable to move ticket.');
   }
 
-  // Move the ticket, making it an update on another ticket.
+// Move the ticket, making it an update on another ticket.
   $max = db_query('SELECT MAX(thread) FROM {comment} WHERE nid = :nid', array(':nid' => $destination->nid))->fetchField();
-  // Strip the "/" from the end of the thread.
+// Strip the "/" from the end of the thread.
   $max = rtrim($max, '/');
-  // Finally, build the thread field for this new comment.
+// Finally, build the thread field for this new comment.
   $thread = int2vancode(vancode2int($max) + 1) . '/';
   $account = user_load($node->uid);
-  // TODO Please review the conversion of this statement to the D7 database API syntax.
+// TODO Please review the conversion of this statement to the D7 database API syntax.
   /* db_query("INSERT INTO {
     comments
     } (nid, pid, uid, subject, comment, format, hostname, timestamp, status, thread, name, mail, homepage) VALUES (%d, %d, %d, '%s', '%s', %d, '%s', %d, %d, '%s', '%s', '%s', '%s')", $destination->nid, 0, $node->uid, $node->title, $node->body, 1, ip_address(), $node->changed, 0, $thread, $account->name, $account->mail, $account->homepage) */
@@ -1223,7 +1223,7 @@ function _support_node_move($node, $destination) {
           ))
           ->execute();
 
-  // Tell the other modules a new comment has been submitted.
+// Tell the other modules a new comment has been submitted.
   $comment = array();
   $comment['cid'] = db_last_insert_id('comments', 'cid');
   $comment['subject'] = $node->title;
@@ -1233,33 +1233,33 @@ function _support_node_move($node, $destination) {
   $comment['message_id'] = db_query('SELECT message_id FROM {support_ticket} WHERE nid = :nid', array(':nid' => $node->nid))->fetchField();
   $comment['support_email'] = TRUE;
   $comment['notification'] = db_query('SELECT active FROM {support_assigned} WHERE nid = :nid AND uid = :uid', array(':nid' => $destination->nid, ':uid' => $account->uid))->fetchField();
-  // Preserve the existing values for the support ticket status.
+// Preserve the existing values for the support ticket status.
   $comment['state'] = $destination->state;
   $comment['priority'] = $destination->priority;
   $comment['client'] = $destination->client;
   $comment['assigned'] = $destination->assigned;
   comment_invoke_comment($comment, 'insert');
 
-  // transfer attachments
+// transfer attachments
   if (db_table_exists('upload')) {
     if (module_exists('comment_upload')) {
-      // transfer attachments to new comment
+// transfer attachments to new comment
       $result = db_query('SELECT fid, description, list, weight FROM {upload} WHERE nid = :nid', array(':nid' => $node->nid));
       foreach ($result as $upload) {
-        // TODO Please convert this statement to the D7 database API syntax.
+// TODO Please convert this statement to the D7 database API syntax.
         /* db_query("INSERT INTO {
           comment_upload
           } (fid, nid, cid, description, list, weight) VALUES(%d, %d, %d, '%s', %d, %d)", $upload->fid, $destination->nid, $comment['cid'], $upload->description, $upload->list, $upload->weight) */
         NULL;
       }
-      // TODO Please review the conversion of this statement to the D7 database API syntax.
+// TODO Please review the conversion of this statement to the D7 database API syntax.
       /* db_query('DELETE FROM {upload} WHERE nid = %d', $node->nid) */
       db_delete('upload')
               ->condition('nid', $node->nid)
               ->execute();
     } else {
-      // transfer attachments to new node
-      // TODO Please review the conversion of this statement to the D7 database API syntax.
+// transfer attachments to new node
+// TODO Please review the conversion of this statement to the D7 database API syntax.
       /* db_query('UPDATE {upload} SET nid = %d WHERE nid = %d', $destination->nid, $node->nid) */
       db_update('upload')
               ->fields(array(
@@ -1270,7 +1270,7 @@ function _support_node_move($node, $destination) {
     }
   }
 
-  // add an entry to the watchdog log
+// add an entry to the watchdog log
   watchdog('content', 'Comment: added %subject.', array('%subject' => $comment->subject), WATCHDOG_NOTICE, l(t('view'), 'node/' . $comment->nid, array('fragment' => 'comment-' . $comment->cid)));
 
   $result = db_query('SELECT cid, uid, subject, comment, format, hostname, timestamp, timestamp, status, thread, name, mail, homepage FROM {comment} WHERE nid = :nid', array(':nid' => $node->nid));
@@ -1278,7 +1278,7 @@ function _support_node_move($node, $destination) {
     $oldcid = $update['cid'];
     $max = rtrim($thread, '/');
     $thread = int2vancode(vancode2int($max) + 1) . '/';
-    // TODO Please review the conversion of this statement to the D7 database API syntax.
+// TODO Please review the conversion of this statement to the D7 database API syntax.
     /* db_query("INSERT INTO {
       comments
       } (nid, pid, uid, subject, comment, format, hostname, timestamp, status, thread, name, mail, homepage) VALUES (%d, %d, %d, '%s', '%s', %d, '%s', %d, %d, '%s', '%s', '%s', '%s')", $destination->nid, 0, $update['uid'], $update['subject'], $update['comment'], $update['format'], $update['hostname'], $update['timestamp'], $update['status'], $thread, $update['name'], $update['mail'], $update['homepage']) */
@@ -1299,22 +1299,22 @@ function _support_node_move($node, $destination) {
                 'homepage' => $update['homepage'],
             ))
             ->execute();
-    // Tell the other modules a new comment has been submitted.
+// Tell the other modules a new comment has been submitted.
     $update['cid'] = db_last_insert_id('comments', 'cid');
     $update['nid'] = $destination->nid;
     $comment['message_id'] = db_query('SELECT message_id FROM {support_ticket_comment} WHERE cid = :cid', array(':cid' => $oldcid));
     $update['support_email'] = TRUE;
     $update['notification'] = $comment['notification'];
-    // Preserve the existing values for the support ticket status.
+// Preserve the existing values for the support ticket status.
     $update['state'] = $destination->state;
     $update['priority'] = $destination->priority;
     $update['client'] = $destination->client;
     $update['assigned'] = $destination->assigned;
     comment_invoke_comment($update, 'insert');
 
-    // transfer attachments to new comment
+// transfer attachments to new comment
     if (module_exists('comment_upload')) {
-      // TODO Please review the conversion of this statement to the D7 database API syntax.
+// TODO Please review the conversion of this statement to the D7 database API syntax.
       /* db_query('UPDATE {comment_upload} SET nid = %d, cid = %d WHERE nid = %d AND cid = %d', $destination->nid, $update['cid'], $node->nid, $oldcid) */
       db_update('comment_upload')
               ->fields(array(
@@ -1328,7 +1328,7 @@ function _support_node_move($node, $destination) {
   }
   _comment_update_node_statistics($comment['nid']);
 
-  // remove the original node
+// remove the original node
   node_delete($node->nid);
 
   drupal_set_message(t('Successfully moved support ticket.'));
@@ -1344,40 +1344,40 @@ function _support_node_move($node, $destination) {
 function support_mail_tokens($account, $language, $nid, $comment, $suppress) {
   global $base_url, $user;
   static $reset = TRUE;
-  // force reload node from database to get updated state/priority information,
-  // but no need to reset it multiple times when sending multiple notifications
+// force reload node from database to get updated state/priority information,
+// but no need to reset it multiple times when sending multiple notifications
   $node = node_load($nid, NULL, $reset);
   $assigned = user_load($node->assigned);
   $reset = FALSE;
-  if (isset($comment['cid'])) {
-    $cid = $comment['cid'];
-    // TODO Convert "user_load" to "user_load_multiple" if "$comment['uid']" is other than a uid.
-    // To return a single user object, wrap "user_load_multiple" with "array_shift" or equivalent.
-    // Example: array_shift(user_load_multiple(array(), $comment['uid']))
-    $update_account = user_load($comment['uid']);
+  if (isset($comment->cid)) {
+    $cid = $comment->cid;
+// TODO Convert "user_load" to "user_load_multiple" if "$comment['uid']" is other than a uid.
+// To return a single user object, wrap "user_load_multiple" with "array_shift" or equivalent.
+// Example: array_shift(user_load_multiple(array(), $comment['uid']))
+    $update_account = user_load($comment->uid);
   } else {
     $cid = 0;
-    // TODO Convert "user_load" to "user_load_multiple" if "$node->uid" is other than a uid.
-    // To return a single user object, wrap "user_load_multiple" with "array_shift" or equivalent.
-    // Example: array_shift(user_load_multiple(array(), $node->uid))
+// TODO Convert "user_load" to "user_load_multiple" if "$node->uid" is other than a uid.
+// To return a single user object, wrap "user_load_multiple" with "array_shift" or equivalent.
+// Example: array_shift(user_load_multiple(array(), $node->uid))
     $update_account = user_load($node->uid);
   }
   $client = support_client_load($node->client);
   $ticket_unsubscribe_key = md5($account->uid . $node->nid);
   $all_unsubscribe_key = md5($account->uid);
-  $previous_comment = db_query_range('SELECT cid FROM {comment} WHERE nid = :nid ORDER BY cid DESC', array(':nid' => $nid))->fetchField();
+  $previous_comment = db_query_range('SELECT cid FROM {comment} WHERE nid = :nid ORDER BY cid DESC', 0, 1, array(':nid' => $nid))->fetchField();
   if ($previous_comment) {
-    $previous = db_query('SELECT * FROM {support_ticket_comment} WHERE cid = :cid', array(':cid' => $previous_comment));
+    $previous = db_query('SELECT * FROM {support_ticket_comment} WHERE cid = :cid', array(':cid' => $previous_comment))->fetchObject();
   }
-  // TODO Please change this theme call to use an associative array for the $variables parameter.
-  // TODO Please change this theme call to use an associative array for the $variables parameter.
+// TODO Please change this theme call to use an associative array for the $variables parameter.
+// TODO Please change this theme call to use an associative array for the $variables parameter.
   $tokens = array(
       '!username' => $account->name,
       '!client_name' => $client->name,
       '!client_path' => $client->path,
       '!key' => '[' . variable_get('support_key', 'tkt') . ":$nid]",
       '!update_username' => isset($update_account->name) ? $update_account->name : '',
-      '!update_realname' => theme('username', $user, array('plain' => TRUE)),
+      '!update_realname' => theme('username', array('account' => $user)),
       '!site' => variable_get('site_name', 'Drupal'),
       '!uri' => $base_url,
       '!uri_brief' => preg_replace('!^https?://!', '', $base_url),
@@ -1385,14 +1385,14 @@ function support_mail_tokens($account, $language, $nid, $comment, $suppress) {
       '!mailto' => $account->mail,
       '!date' => format_date(REQUEST_TIME, 'medium', '', NULL, $language->language),
       '!ticket_subject' => check_plain($node->title),
-      '!ticket_body' => $suppress ? t('The text of this ticket was manually suppressed.  You must view the ticket online to see it.') . "\n" : drupal_html_to_text(check_markup($node->body) . _support_mail_list_attachments($node, $comment)),
+      '!ticket_body' => $suppress ? t('The text of this ticket was manually suppressed.  You must view the ticket online to see it.') . "\n" : drupal_html_to_text(check_markup($node->body[$node->language][0]['value']) . _support_mail_list_attachments($node, $comment)),
       '!ticket_url' => url("node/$nid", array('absolute' => TRUE, 'language' => $language, 'fragment' => "comment-$cid", 'alias' => variable_get('support_use_aliased_urls', TRUE))),
       '!update_url' => url("node/$nid", array('absolute' => TRUE, 'language' => $language, 'fragment' => "comment-form", 'alias' => variable_get('support_use_aliased_urls', TRUE))),
-      '!update' => $suppress ? t('The text of this ticket update was manually suppressed.  You must view the ticket online to see the update.') . "\n" : drupal_html_to_text(check_markup(isset($comment['comment']) ? $comment['comment'] : '') . _support_mail_list_attachments($node, $comment)),
+      '!update' => $suppress ? t('The text of this ticket update was manually suppressed.  You must view the ticket online to see the update.') . "\n" : drupal_html_to_text(check_markup(isset($comment->comment_body[$comment->language][0]) ? $comment->comment_body[$comment->language][0]['value'] : '') . _support_mail_list_attachments($node, $comment)),
       '!state' => ((isset($previous->state) && $previous->state != $node->state) ? _support_state($previous->state) . ' -> ' : '') . _support_state($node->state),
       '!priority' => ((isset($previous->priority) && $previous->priority != $node->priority) ? _support_priorities($previous->priority) . ' -> ' : '') . _support_priorities($node->priority),
       '!assigned_username' => !empty($assigned) ? $assigned->name : '',
-      '!assigned_realname' => !empty($assigned) ? theme('username', $assigned, array('plain' => TRUE)) : '',
+      '!assigned_realname' => !empty($assigned) ? theme('username', array('account' => $assigned)) : '',
       '!unsubscribe_ticket' => url("support/$nid/unsubscribe/$account->uid/$ticket_unsubscribe_key", array('absolute' => TRUE, 'language' => $language, 'alias' => variable_get('support_use_aliased_urls', TRUE))),
       '!unsubscribe_all' => url("support/all/unsubscribe/$account->uid/$all_unsubscribe_key", array('absolute' => TRUE, 'language' => $language, 'alias' => variable_get('support_use_aliased_urls', TRUE))),
   );
@@ -1411,11 +1411,15 @@ function _support_mail_list_attachments($node, $comment) {
     foreach ($node->files as $fid => $file) {
       $attachments[] = url($file->filepath, array('absolute' => TRUE, 'alias' => variable_get('support_user_aliased_urls', TRUE)));
     }
-  } else if (isset($comment['files']) && is_array($comment['files'])) {
+  }
+  /* TODO
+   * comment_upload dont has a D7 port
+    else if (isset($comment['files']) && is_array($comment['files'])) {
     foreach ($comment['files'] as $fid => $file) {
-      $attachments[] = url($file['filepath'], array('absolute' => TRUE, 'alias' => variable_get('support_use_aliased_urls', TRUE)));
+    $attachments[] = url($file['filepath'], array('absolute' => TRUE, 'alias' => variable_get('support_use_aliased_urls', TRUE)));
     }
-  }
+    }
+   */
   return (!empty($attachments) ? "<br />" . t('Attachments:') . "<br />" . implode("<br />", $attachments) : '');
 }
 
@@ -1425,9 +1429,9 @@ function _support_mail_list_attachments($node, $comment) {
 function _support_mail_text($key, $language = NULL, $variables = array(), $integrate_email) {
   $langcode = isset($language) ? $language->language : NULL;
 
-  // Add one 'special unadvertised token' to $variables.
-  // This part of the text is not stored as a multilingual variable
-  // but as a 'common' translatable string.
+// Add one 'special unadvertised token' to $variables.
+// This part of the text is not stored as a multilingual variable
+// but as a 'common' translatable string.
   if ($integrate_email == TRUE) {
     $variables['!reply'] = t('You can reply to this email or visit the following URL to update this ticket');
   } else {
@@ -1489,115 +1493,114 @@ function _support_mail_text_default($key) {
  */
 function support_save_message($message, $client) {
   if (isset($message['uid'])) {
-    // TODO Convert "user_load" to "user_load_multiple" if "$message['uid']" is other than a uid.
-    // To return a single user object, wrap "user_load_multiple" with "array_shift" or equivalent.
-    // Example: array_shift(user_load_multiple(array(), $message['uid']))
+// TODO Convert "user_load" to "user_load_multiple" if "$message['uid']" is other than a uid.
+// To return a single user object, wrap "user_load_multiple" with "array_shift" or equivalent.
+// Example: array_shift(user_load_multiple(array(), $message['uid']))
     $account = user_load($message['uid']);
   } else {
     $account = support_account_load($message['from'], $message['nid'], $message['subject'], $client);
   }
   $ticket = support_ticket_load($message['nid']);
 
-  if (array_key_exists('headers') && is_object($message['headers']) && isset($message['headers']->message_id)) {
+  if (array_key_exists('headers', $message) && is_object($message['headers']) && isset($message['headers']->message_id)) {
     $message_id = $message['headers']->message_id;
   } else {
     $message_id = NULL;
   }
 
   if (is_object($account) && is_object($ticket) && $ticket->nid) {
-    // by retrieving the maximum thread level.
+// by retrieving the maximum thread level.
     $max = db_query('SELECT MAX(thread) FROM {comment} WHERE nid = :nid', array(':nid' => $ticket->nid))->fetchField();
-    // Strip the "/" from the end of the thread.
+// Strip the "/" from the end of the thread.
     $max = rtrim($max, '/');
     // Finally, build the thread field for this new comment.
     $thread = int2vancode(vancode2int($max) + 1) . '/';
 
-    // TODO: format?
-    // TODO: ip_address?
-    // TODO Please review the conversion of this statement to the D7 database API syntax.
-    /* db_query("INSERT INTO {
-      comments
-      } (nid, pid, uid, subject, comment, format, hostname, timestamp, status, thread, name, mail, homepage) VALUES (%d, %d, %d, '%s', '%s', %d, '%s', %d, %d, '%s', '%s', '%s', '%s')", $ticket->nid, 0, $account->uid, $message['subject'], $message['body'], 1, ip_address(), REQUEST_TIME, 0, $thread, $account->name, $account->mail, isset($account->homepage) ? $account->homepage : '') */
-    $id = db_insert('comment')
-            ->fields(array(
-                'nid' => $ticket->nid,
-                'pid' => 0,
-                'uid' => $account->uid,
-                'subject' => $message['subject'],
-                'comment' => $message['body'],
-                'format' => 1,
-                'hostname' => ip_address(),
-                'timestamp' => REQUEST_TIME,
-                'status' => 0,
-                'thread' => $thread,
-                'name' => $account->name,
-                'mail' => $account->mail,
-                'homepage' => isset($account->homepage) ? $account->homepage : '',
-            ))
-            ->execute();
-
-    // Tell the other modules a new comment has been submitted.
-    $comment['cid'] = db_last_insert_id('comments', 'cid');
-    $comment['subject'] = $message['subject'];
-    $comment['comment'] = $message['body'];
-    $comment['nid'] = $ticket->nid;
-    $comment['uid'] = $account->uid;
-    $comment['message_id'] = $message_id;
-    $comment['state'] = isset($message['state']) ? $message['state'] : $ticket->state;
-    $comment['priority'] = isset($message['priority']) ? $message['priority'] : $ticket->priority;
-    $comment['client'] = $ticket->client;
-    $comment['assigned'] = isset($message['assigned']) ? $message['assigned'] : $ticket->assigned;
-    $comment['notification'] = db_query('SELECT active FROM {support_assigned} WHERE nid = :nid AND uid = :uid', array(':nid' => $ticket->nid, ':uid' => $account->uid))->fetchField();
-    $comment['support_email'] = TRUE;
-    $comment['files'] = _support_save_attachments($message['attachments'], $account);
+    $comment = new stdClass();
+    $comment->cid = NULL;
+    $comment->pid = 0;
+    $comment->uid = $account->uid;
+    $comment->nid = $ticket->nid;
+    $comment->status = COMMENT_PUBLISHED;
+    $comment->thread = $thread;
+    $comment->subject = $message['subject'];
+    $comment->hostname = ip_address();
+    $comment->language = LANGUAGE_NONE;
+    $comment->name = $account->name;
+    $comment->mail = $account->mail;
+    $comment->subject = $message['subject'];
+    $comment->timestamp = REQUEST_TIME;
+    $comment->comment_body = array(LANGUAGE_NONE => array($message['body']));
+// TODO
+// It seems http://drupal.org/project/comment_upload has no D7 port yet?
+// $comment->files = _support_save_attachments($message['attachments'], $account);
+    $comment->message_id = $message_id;
+    $comment->state = isset($message['state']) ? $message['state'] : $ticket->state;
+    $comment->priority = isset($message['priority']) ? $message['priority'] : $ticket->priority;
+    $comment->client = $ticket->client;
+    $comment->assigned = isset($message['assigned']) ? $message['assigned'] : $ticket->assigned;
+    $active = db_query('SELECT active FROM {support_assigned} WHERE nid = :nid AND uid = :uid', array(':nid' => $ticket->nid, ':uid' => $account->uid))->fetchField();
+    if ($active !== false)
+      $comment->notification = $active;
+    else
+      $comment->notification = 1;
+    $comment->support_email = 1;
     if (isset($message['suppress'])) {
-      $comment['suppress'] = $message['suppress'];
+      $comment->suppress = $message['suppress'];
     }
-    // convert indivudal files to arrays to work with the comment_upload module
-    foreach ($comment['files'] as $fid => $file) {
+
+    comment_save($comment);
+
+    /* TODO
+     * It seems http://drupal.org/project/comment_upload has no D7 port yet?
+      // convert indivudal files to arrays to work with the comment_upload module
+      foreach ($comment['files'] as $fid => $file) {
       $comment['files'][$fid] = (array) $file;
-    }
-    if (isset($message['_support_extra_fields'])) {
+      }
+      if (isset($message['_support_extra_fields'])) {
       foreach ($message['_support_extra_fields'] as $k => $v) {
-        $comment[$k] = $v;
+      $comment[$k] = $v;
       }
-    }
-    comment_invoke_comment($comment, 'insert');
+      }
+     */
 
-    // Add an entry to the watchdog log.
-    watchdog('content', 'Comment: added %subject.', array('%subject' => $comment['subject']), WATCHDOG_NOTICE, l(t('view'), 'node/' . $comment['nid'], array('fragment' => 'comment-' . $comment['cid'])));
-    _comment_update_node_statistics($comment['nid']);
+// Add an entry to the watchdog log.
+    watchdog('content', 'Comment: added %subject.', array('%subject' => $comment->subject), WATCHDOG_NOTICE, l(t('view'), 'node/' . $comment->nid, array('fragment' => 'comment-' . $comment->cid)));
+    _comment_update_node_statistics($comment->nid);
 
-    // Clear the cache so an anonymous user can see his comment being added.
+// Clear the cache so an anonymous user can see his comment being added.
     cache_clear_all();
     return TRUE;
   } else if (is_object($account)) {
     $node = new stdClass();
-    // Create new ticket if none matches and valid from address.
+// Create new ticket if none matches and valid from address.
     $node->title = $message['subject'];
     $node->body = $message['body'];
     $node->type = 'support_ticket';
     $node->log = t('Support ticket created from email.');
-    $node->comment = COMMENT_NODE_READ_WRITE;
     $node->uid = $account->uid;
     $node->message_id = $message_id;
     $node->state = isset($message['state']) ? $message['state'] : _support_state_default();
     $node->priority = isset($message['priority']) ? $message['priority'] : _support_priority_default();
     $node->client = $client->clid;
     $node->assigned = _support_autoassign($client->clid, $account->uid);
-    $node->notification = TRUE;
-    $node->support_email = TRUE;
+    $node->notification = 1;
+    $node->support_email = 1;
     $node->language = $account->language;
-    // Save/record attachments
-    if (isset($message['attachments'])) {
+    $node->created_by_email = 1;
+    /* TODO
+     * It seems http://drupal.org/project/comment_upload has no D7 port yet?
+      // Save/record attachments
+      if (isset($message['attachments'])) {
       $node->files = _support_save_attachments($message['attachments'], $account);
-    }
-    $node->created_by_email = TRUE;
-    if (isset($message['_support_extra_fields'])) {
+      }
+      if (isset($message['_support_extra_fields'])) {
       foreach ($message['_support_extra_fields'] as $k => $v) {
-        $node->{$k} = $v;
+      $node->{$k} = $v;
       }
-    }
+      }
+     * 
+     */
     node_save($node);
   }
 }
@@ -1619,7 +1622,7 @@ function _support_save_attachments($attachments, $account) {
               $attachment->filename = urldecode($parm->value);
               break;
             default:
-              // put everything else in the attributes array;
+// put everything else in the attributes array;
               $attachment->attributes[$parm->attribute] = $parm->value;
           }
         }
@@ -1632,7 +1635,7 @@ function _support_save_attachments($attachments, $account) {
               $attachment->filename = $parm->value;
               break;
             default:
-              // put everything else in the attributes array;
+// put everything else in the attributes array;
               $attachment->attributes[$parm->attribute] = $parm->value;
           }
         }
@@ -1647,7 +1650,7 @@ function _support_save_attachments($attachments, $account) {
       $attachment->filepath = file_save_data($attachment->attachment, file_directory_path() . '/' . utf8_encode($attachment->filename));
       if ($attachment->filepath) {
         watchdog('support', 'Saved %size byte %type attachment %file to %path.', array('%size' => number_format($attachment->bytes), '%type' => $attachment->filemime, '%file' => utf8_encode($attachment->filename), '%path' => $attachment->filepath), WATCHDOG_INFO);
-        // TODO Please convert this statement to the D7 database API syntax.
+// TODO Please convert this statement to the D7 database API syntax.
         /* db_query("INSERT INTO {
           files
           } (uid, filename, filepath, filemime, filesize, status, timestamp) VALUES(%d, '%s', '%s', '%s', %d, %d, %d)", $account->uid, utf8_encode($attachment->filename), $attachment->filepath, $attachment->filemime, $attachment->bytes, 1, REQUEST_TIME) */
@@ -1682,13 +1685,13 @@ function _support_get_attachments($stream, $message, $structure, $parts) {
   for ($part = 2; $part <= $parts; $part++) {
     $attachment = imap_fetchbody($stream, $message, $part);
     $details = imap_bodystruct($stream, $message, $part);
-    // Decode as necessary
+// Decode as necessary
     if ($details->encoding == ENCBASE64) {
       $attachment = imap_base64($attachment);
     } else if ($details->encoding == ENCQUOTEDPRINTABLE) {
       $attachment = quoted_printable_decode($attachment);
     }
-    // Convert text attachment to UTF-8
+// Convert text attachment to UTF-8
     else if ($details->type == TYPETEXT) {
       $attachment = imap_utf8($attachment);
     }
@@ -1745,13 +1748,13 @@ function _support_get_message_body_part($stream, $message, $mime_type, $structur
 function _support_get_message_body($stream, $message, $mime_type, $structure = FALSE, $part = FALSE) {
   $body = _support_get_message_body_part($stream, $message, $mime_type, $structure, $part);
 
-  // If reply includes complete unchanged copy of ticket notification, strip
-  // it.
+// If reply includes complete unchanged copy of ticket notification, strip
+// it.
   $stripped = FALSE;
   $array = explode("\n", $body);
   $last_line = $last_length = 0;
   foreach ($array as $line => $text) {
-    // Look for last occurrance of magic in previous ticket.
+// Look for last occurrance of magic in previous ticket.
     preg_match_all("/([0-9]*):([0-9a-f]*)\]/", $text, $magic);
     if (!empty($magic[0][0])) {
       foreach ($magic[1] as $key => $length) {
@@ -1760,24 +1763,24 @@ function _support_get_message_body($stream, $message, $mime_type, $structure = F
       }
     }
   }
-  // Strip old ticket if quoted with "> " as most mail clients do.
+// Strip old ticket if quoted with "> " as most mail clients do.
   $start = $last_line - $last_length;
   if ($last_length) {
     for ($current = $last_line; substr($array[$current], 0, 2) == '> '; $current--) {
       $stripped = TRUE;
       unset($array[$current]);
     }
-    // If stripped entire ticket, strip one more line as most mail clients
-    // include a line saying who the message was by.  If we only stripped
-    // part of the message, someone probably edited inline so we just stop
-    // at first unquoted line.
+// If stripped entire ticket, strip one more line as most mail clients
+// include a line saying who the message was by.  If we only stripped
+// part of the message, someone probably edited inline so we just stop
+// at first unquoted line.
     if ($current <= $start) {
       unset($array[$current]);
     }
   }
 
   if ($stripped) {
-    // The ticket has been stripped of previous ticket text, rebuild it.
+// The ticket has been stripped of previous ticket text, rebuild it.
     $body = '';
     foreach ($array as $line) {
       $body .= $line . "\n";
@@ -1795,24 +1798,31 @@ function support_subscribe_user($nid, $uid, $active = 1) {
   $client = support_client_load($clid);
   $account = user_load($uid);
   if (support_access_clients($client, $account)) {
-    // TODO Please review the conversion of this statement to the D7 database API syntax.
+// TODO Please review the conversion of this statement to the D7 database API syntax.
     /* db_query('UPDATE {support_assigned} SET active = %d WHERE uid = %d AND nid = %d', $active, $uid, $nid) */
-    $update = db_update('support_assigned')
-            ->fields(array(
-                'active' => $active,
-            ))
-            ->condition('uid', $uid)
-            ->condition('nid', $nid)
-            ->execute();
-    if ($update == 0) {
+    $is_assigned = db_select('support_assigned', 'a')
+                    ->condition('uid', $uid)
+                    ->condition('nid', $nid)
+                    ->fields('a')
+                    ->execute()->rowCount();
+
+    if ($is_assigned) {
+      $update = db_update('support_assigned')
+              ->fields(array(
+                  'active' => $active,
+              ))
+              ->condition('uid', $uid)
+              ->condition('nid', $nid)
+              ->execute();
+    } else {
       db_insert('support_assigned')
               ->fields(array('nid' => $nid, 'uid' => $uid, 'active' => $active))
               ->execute();
     }
   } else {
-    // If this user doesn't have permission to receive ticket updates,
-    // be sure they are unsubscribed.
-    // TODO Please review the conversion of this statement to the D7 database API syntax.
+// If this user doesn't have permission to receive ticket updates,
+// be sure they are unsubscribed.
+// TODO Please review the conversion of this statement to the D7 database API syntax.
     /* db_query('UPDATE {support_assigned} SET active = 0 WHERE uid = %d AND nid = %d', $uid, $nid) */
     db_update('support_assigned')
             ->fields(array(
@@ -1885,8 +1895,8 @@ function _support_mail_notify($op, $account, $comment = array(), $nid = NULL, $s
     $node = node_load($nid);
     $params['account'] = $account;
     $params['nid'] = $nid;
-    if (isset($comment['cid'])) {
-      $params['cid'] = $comment['cid'];
+    if (isset($comment->cid)) {
+      $params['cid'] = $comment->cid;
       $params['comment'] = $comment;
     } else {
       $params['cid'] = 0;
@@ -1900,7 +1910,7 @@ function _support_mail_notify($op, $account, $comment = array(), $nid = NULL, $s
       $mailfrom = variable_get('support_global_mailfrom', '');
     }
     $mail = drupal_mail('support', $op, $account->mail, $language, $params, $mailfrom);
-    // TODO: notify admins as necessary
+// TODO: notify admins as necessary
   }
   return empty($mail) ? NULL : $mail['result'];
 }
@@ -1912,7 +1922,7 @@ function _support_comment_update_node($nid) {
   $cid = db_query('SELECT MAX(cid) FROM {comment} WHERE nid = :nid', array(':nid' => $nid))->fetchField();
   if ($cid) {
     $comment = db_select('support_ticket_comment', 't')->condition('t.cid', $cid)->fields('t')->execute()->fetchObject();
-    // TODO Please review the conversion of this statement to the D7 database API syntax.
+// TODO Please review the conversion of this statement to the D7 database API syntax.
     /* db_query('UPDATE {support_ticket} SET state = %d, priority = %d, client = %d, assigned = %d WHERE nid = %d', $comment->state, $comment->priority, $comment->client, $comment->assigned, $nid) */
     db_update('support_ticket')
             ->fields(array(
@@ -1950,7 +1960,7 @@ function support_form_alter(&$form, &$form_state, $form_id) {
     $form['#submit'] = array('support_search_form_submit');
   }
   if ($form_id == 'search_form' && $form['module']['#value'] == 'support' && user_access('use advanced search')) {
-    // Keyword boxes:
+// Keyword boxes:
     $form['advanced'] = array(
         '#type' => 'fieldset',
         '#title' => t('Advanced search'),
@@ -1986,7 +1996,7 @@ function support_form_alter(&$form, &$form_state, $form_id) {
         '#prefix' => '<div class="action">',
         '#suffix' => '</div>',
     );
-    // Clients
+// Clients
     $clients = _support_available_clients();
     if (sizeof($clients) > 1) {
       $form['advanced']['client'] = array(
@@ -1998,7 +2008,7 @@ function support_form_alter(&$form, &$form_state, $form_id) {
           '#options' => $clients,
       );
     }
-    // States
+// States
     $states = _support_states();
     if (sizeof($states) > 1) {
       $form['advanced']['state'] = array(
@@ -2010,7 +2020,7 @@ function support_form_alter(&$form, &$form_state, $form_id) {
           '#options' => $states,
       );
     }
-    // Priorities
+// Priorities
     $priorities = _support_priorities();
     if (sizeof($priorities) > 1) {
       $form['advanced']['priority'] = array(
@@ -2031,10 +2041,10 @@ function support_form_alter(&$form, &$form_state, $form_id) {
  * Form API callback for the search form. Registered in support_form_alter().
  */
 function support_search_validate($form, &$form_state) {
-  // Initialise using any existing basic search keywords.
+// Initialise using any existing basic search keywords.
   $keys = $form_state['values']['processed_keys'];
 
-  // Insert extra restrictions into the search keywords string.
+// Insert extra restrictions into the search keywords string.
   if (isset($form_state['values']['client']) && is_array($form_state['values']['client'])) {
     if (count($form_state['values']['client'])) {
       $keys = search_query_insert($keys, 'client', implode(',', array_keys($form_state['values']['client'])));
@@ -2124,7 +2134,7 @@ function support_search_available_clients() {
 function support_search_execute($keys, $conditions) {
   $arguments = array();
 
-  // clients
+// clients
   if ($client = search_expression_extract($keys, 'client')) {
     $clients = array();
     foreach (explode(',', $client) as $c) {
@@ -2134,7 +2144,7 @@ function support_search_execute($keys, $conditions) {
     $conditions .= ' AND (' . implode(' OR ', $clients) . ')';
     $keys = search_expression_insert($keys, 'client');
   }
-  // states
+// states
   if ($state = search_expression_extract($keys, 'state')) {
     $states = array();
     foreach (explode(',', $state) as $s) {
@@ -2144,7 +2154,7 @@ function support_search_execute($keys, $conditions) {
     $conditions .= ' AND (' . implode(' OR ', $states) . ')';
     $keys = search_expression_insert($keys, 'state');
   }
-  // priorities
+// priorities
   if ($priority = search_expression_extract($keys, 'priority')) {
     $priorities = array();
     foreach (explode(',', $priority) as $p) {
@@ -2161,7 +2171,7 @@ function support_search_execute($keys, $conditions) {
     $join .= " LEFT JOIN {support_ticket} jt ON n.nid = jt.nid";
     $conditions .= ' AND jt.client IN (' . implode(',', support_search_available_clients()) . ')';
   } else {
-    // User can not access any tickets
+// User can not access any tickets
     $conditions .= " AND n.type != 'support_ticket'";
   }
   if (!user_access('view other users tickets') && !user_access('administer support') && !user_access('edit any ticket') && !user_access('delete any ticket')) {
@@ -2176,26 +2186,26 @@ function support_search_execute($keys, $conditions) {
           ->addTag('node_access')
           ->searchExpression($keys, 'node');
 
-  // Add the ranking expressions.
+// Add the ranking expressions.
   _node_rankings($query);
 
-  // Add additional modifiers here...
+// Add additional modifiers here...
   $find = $query
           ->limit(10)
           ->execute();
 
-  // Load results.
+// Load results.
   $results = array();
   foreach ($find as $item) {
-    // Build the node body.
+// Build the node body.
     $node = node_load($item->sid);
     $node->build_mode = NODE_BUILD_SEARCH_RESULT;
     $node = node_build_content($node, FALSE, FALSE);
     $node->body = drupal_render($node->content);
 
-    // Fetch comments for snippet.
+// Fetch comments for snippet.
     $node->body .= module_invoke('comment', 'nodeapi', $node, 'update index');
-    // Fetch terms for snippet.
+// Fetch terms for snippet.
     $node->body .= module_invoke('taxonomy', 'nodeapi', $node, 'update index');
 
     $extra = module_invoke_all('node_search_result', $node);
@@ -2207,7 +2217,7 @@ function support_search_execute($keys, $conditions) {
     } else {
       $title = $node->title;
     }
-    // change 'comments' to 'follow ups' for support tickets
+// change 'comments' to 'follow ups' for support tickets
     foreach ($extra as $key => $value) {
       $trans = array(' comments' => ' follow ups');
       $extra[$key] = strtr($value, $trans);
@@ -2255,15 +2265,15 @@ function support_status_form(&$form_state, $edit, $title) {
       $node = node_load($edit['nid']);
     }
   }
-  // Form preview, $edit is object.
+// Form preview, $edit is object.
   else {
     $node = $edit;
   }
   $autoassign = _support_autoassign(_support_current_client(), $user->uid);
   if ($autoassign && !isset($node->assigned) &&
           (!isset($node->nid) || !$node->nid)) {
-    // This ticket is being created, and this module is configured to
-    // auto-assign new tickets.
+// This ticket is being created, and this module is configured to
+// auto-assign new tickets.
     $node->assigned = $autoassign;
   }
   if ($cid) {
@@ -2288,8 +2298,8 @@ function support_status_form(&$form_state, $edit, $title) {
   }
   $default = isset($node->state) ? $node->state : _support_state_default();
   if ($node->uid != $user->uid && $default == _support_state_default()) {
-    // We did not create this ticket, but we're updating it.  Suggest that it
-    // no longer be marked as new.
+// We did not create this ticket, but we're updating it.  Suggest that it
+// no longer be marked as new.
     $default = _support_state_secondary();
   }
   if (!user_access('can select state') &&
@@ -2335,9 +2345,9 @@ function support_status_form(&$form_state, $edit, $title) {
       if (isset($_SESSION['support_client']) && is_numeric($_SESSION['support_client'])) {
         $node->client = $_SESSION['support_client'];
       } else if (!user_access('can select client')) {
-        // TODO: It should be possible to set a default client.  Perhaps allow
-        // a weight to be assigned to clients -- then we select the heaviest
-        // matching client...?
+// TODO: It should be possible to set a default client.  Perhaps allow
+// a weight to be assigned to clients -- then we select the heaviest
+// matching client...?
         $node->client = key($clients);
       }
     }
@@ -2425,28 +2435,28 @@ function _support_assigned($assigned, $node, $limit = 9999) {
 
   if (!isset($available["$assigned-$node->nid"])) {
     if ($assigned && ($assigned != $user->uid)) {
-      // TODO Convert "user_load" to "user_load_multiple" if "$assigned" is other than a uid.
-      // To return a single user object, wrap "user_load_multiple" with "array_shift" or equivalent.
-      // Example: array_shift(user_load_multiple(array(), $assigned))
+// TODO Convert "user_load" to "user_load_multiple" if "$assigned" is other than a uid.
+// To return a single user object, wrap "user_load_multiple" with "array_shift" or equivalent.
+// Example: array_shift(user_load_multiple(array(), $assigned))
       $account = user_load($assigned);
       $available["$assigned-$node->nid"][$account->uid] = $account->name;
       $counter++;
     }
 
-    // can always re-assign ticket to self
+// can always re-assign ticket to self
     $available["$assigned-$node->nid"][$user->uid] = $user->name;
     $counter++;
 
     if (isset($node->client) && is_numeric($node->client) && (user_access('administer support') || user_access('can assign tickets to any user'))) {
       $roles = array();
       $client = db_query('SELECT name FROM {support_client} WHERE clid = :clid', array(':clid' => $node->client))->fetchField();
-      // retrieve all roles giving permission to access current tickets
-      // TODO Please convert this statement to the D7 database API syntax.
+// retrieve all roles giving permission to access current tickets
+// TODO Please convert this statement to the D7 database API syntax.
       $result = db_query("SELECT rid FROM {role_permission} WHERE permission LIKE :clike OR permission LIKE :plike", array(':clike' => '%' . $client . '%', ':plike' => '%administer support%'));
       foreach ($result as $role) {
         $roles[$role->rid] = $role->rid;
       }
-      // retrieve all users in appropriate roles
+// retrieve all users in appropriate roles
       $accounts = array();
       $all = FALSE;
       foreach ($roles as $rid) {
@@ -2649,7 +2659,7 @@ function _support_states($all = TRUE, $sid = NULL, $account = NULL) {
     foreach ($result as $state) {
       $states["$admin-$all-$sid"][$state->sid] = $state->state;
     }
-    // include the current state, even if user doesn't actually have access
+// include the current state, even if user doesn't actually have access
     if ($sid && !in_array($sid, $states["$admin-$all-$sid"])) {
       $states["$admin-$all-$sid"][$sid] = db_query("SELECT state FROM {support_states} WHERE sid = :sid", array(':sid' => $sid))->fetchField();
     }
@@ -2718,7 +2728,7 @@ function _support_priority_default() {
  * Helper function to determine if a user has support tickets already.
  */
 function _support_ticket_exists($account) {
-  // TODO Check if correctly converted to D7 api
+// TODO Check if correctly converted to D7 api
   $result = db_select('node', 'n')
           ->fields('n', array('nid', 'created'))
           ->condition('type', 'support_ticket')
@@ -2806,7 +2816,7 @@ function support_page_form($form, &$form_state, $client = NULL, $state = NULL) {
 
   $form = array();
 
-  // Be sure a client is selected.  If not, select the last visited client.
+// Be sure a client is selected.  If not, select the last visited client.
   if (empty($client)) {
     if (isset($_SESSION['support_client']) && $client = support_client_load($_SESSION['support_client'])) {
       if ($client->parent) {
@@ -2830,7 +2840,7 @@ function support_page_form($form, &$form_state, $client = NULL, $state = NULL) {
     }
   } else {
     if (!empty($client) && !is_numeric($client)) {
-      // TODO: Don't load client then throw it away.
+// TODO: Don't load client then throw it away.
       $client = support_client_load($client, FALSE);
       if (is_object($client)) {
         $client = $client->clid;
@@ -2855,7 +2865,7 @@ function support_page_form($form, &$form_state, $client = NULL, $state = NULL) {
   $form['post-ticket'] = array(
       '#markup' => l(t('Post new support ticket'), 'node/add/support-ticket'),
   );
-  // TODO Please change this theme call to use an associative array for the $variables parameter.
+// TODO Please change this theme call to use an associative array for the $variables parameter.
   $checkboxes = user_access('edit multiple tickets') || user_access('administer support') ? theme('table_select_header_cell') : array();
   $form['header'] = array(
       '#type' => 'value',
@@ -2974,7 +2984,7 @@ function support_page_form($form, &$form_state, $client = NULL, $state = NULL) {
     $form['title'][$ticket->nid] = array('#markup' => l(_support_truncate($ticket->title), "node/$ticket->nid", array('attributes' => array('class' => array('ticket-title')))));
     $form['updated'][$ticket->nid] = array('#markup' => format_date($ticket->last_updated, 'short', array('attributes' => array('class' => array('ticket-updated')))));
     $form['reported'][$ticket->nid] = array('#markup' => l(_support_truncate($account->name, 24), "user/$account->uid", array('attributes' => array('class' => array('ticket-reported')))));
-    // Assigned to
+// Assigned to
     if ((user_access('edit multiple tickets') && user_access('can assign tickets to any user')) || user_access('administer support')) {
       $node = node_load($ticket->nid);
       $options = _support_assigned((isset($assigned->uid) ? $assigned->uid : 0), $node, variable_get('support_autocomplete_limit', 15));
@@ -3009,7 +3019,7 @@ function support_page_form($form, &$form_state, $client = NULL, $state = NULL) {
           '#markup' => l(_support_truncate($assigned->name, 24), "user/$assigned->uid", array('attributes' => array('class' => array('ticket-assigned')))),
       );
     }
-    // State
+// State
     $states = _support_states(FALSE);
     if ((user_access('edit multiple tickets') || user_access('administer support')) && sizeof($states) > 1) {
       $form['state']["state-$ticket->nid"] = array(
@@ -3024,7 +3034,7 @@ function support_page_form($form, &$form_state, $client = NULL, $state = NULL) {
           '#attributes' => array('class' => array('ticket-state')),
       );
     }
-    // Priority
+// Priority
     if (user_access('administer support') || (user_access('edit multiple tickets') && user_access('can select priority'))) {
       $form['priority']["priority-$ticket->nid"] = array(
           '#type' => 'select',
@@ -3093,7 +3103,7 @@ function support_page_form_submit($form, &$form_state) {
     $message = array();
     $message['uid'] = $user->uid;
     $message['nid'] = $nid;
-    // TODO: Allow the optional addition of a subject
+// TODO: Allow the optional addition of a subject
     $message['subject'] = '';
     $message['body'] = $form_state['values']['update'];
     $message['attachments'] = array();
@@ -3101,10 +3111,10 @@ function support_page_form_submit($form, &$form_state) {
     $message['state'] = $form_state['values']["state-$nid"];
     $message['priority'] = $form_state['values']["priority-$nid"];
     $message['assigned'] = $form_state['values']["assigned-$nid"];
-    // TODO: Pass the client in rather than make unnecessary queries
+// TODO: Pass the client in rather than make unnecessary queries
     $clid = db_query('SELECT client FROM {support_ticket} WHERE nid = :nid', array(':nid' => $nid))->fetchField();
     $client = support_client_load($clid);
-    // re-use email handling to save ticket updates
+// re-use email handling to save ticket updates
     support_save_message($message, $client);
   }
 }
@@ -3203,7 +3213,7 @@ function support_client_fetch($client, $manual = TRUE) {
     case 4: // Local file
       $connect = $client->mailbox;
       $username = $password = '';
-      // sanity tests
+// sanity tests
       if (!file_exists($connect) && $manual) {
         drupal_set_message(t('Mail file "%connect" does not exist.', array('%connect' => $connect)), 'error');
       } else if (!is_readable($connect) && $manual) {
@@ -3214,13 +3224,13 @@ function support_client_fetch($client, $manual = TRUE) {
       break;
   }
 
-  // Make a connection to the mail server.
+// Make a connection to the mail server.
   $stream = imap_open($connect, $username, $password);
   if ($stream === FALSE) {
     if ($manual) {
       drupal_set_message(t('Failed to download messages for %client, connection to mail server failed.', array('%client' => $client->name), array('langcode' => 'error')));
       if (user_access('administer support')) {
-        // Dump additional debug if manually calling as administrator
+// Dump additional debug if manually calling as administrator
         drupal_set_message(t('Mail server connection failure: connect(!connect), username(!username), password(!password)', array('!connect' => $connect, '!username' => $username, '!password' => $password)), 'error');
       }
     }
@@ -3248,11 +3258,11 @@ function support_client_fetch($client, $manual = TRUE) {
   }
 
   $messages_downloaded = 0;
-  // check how many messages are available
+// check how many messages are available
   $messages_to_download = imap_num_msg($stream);
   $messages_limit = variable_get('support_download_limit', 1000);
   if ($messages_limit && $messages_limit < $messages_to_download) {
-    // TODO: watchdog, there are more messages available
+// TODO: watchdog, there are more messages available
     $messages_to_download = $messages_limit;
   }
 
@@ -3291,7 +3301,7 @@ function support_client_fetch($client, $manual = TRUE) {
 
     $messages_downloaded++;
 
-    // mark message for deletion
+// mark message for deletion
     imap_delete($stream, $number);
   }
   imap_close($stream, CL_EXPUNGE);
@@ -3313,7 +3323,7 @@ function support_client_fetch($client, $manual = TRUE) {
 function _support_identify_ticket(&$client, &$message) {
   global $base_url;
 
-  // A) Check for ticket number defined in the Subject.
+// A) Check for ticket number defined in the Subject.
   $key = variable_get('support_key', 'tkt');
   $tickets = array();
   preg_match("/(\[$key:)([0-9]*)(\])/", $message['subject'], $tickets);
@@ -3325,13 +3335,13 @@ function _support_identify_ticket(&$client, &$message) {
   if (variable_get('support_thread_by_mail_headers', TRUE)) {
     $id_right = preg_replace('|.+://([a-zA-Z0-9\._-]+).*|', '\1', $base_url);
 
-    // Search In-Reply-To and References...
+// Search In-Reply-To and References...
     $check = '';
     if (isset($message['headers']->in_reply_to)) {
       $check .= $message['headers']->in_reply_to;
     }
     if (isset($message['headers']->references)) {
-      // Turn references header around.
+// Turn references header around.
       $check .= implode(' ', array_reverse(explode(' ', $message['headers']->references)));
     }
     $message_ids = array();
@@ -3339,22 +3349,22 @@ function _support_identify_ticket(&$client, &$message) {
     foreach ($message_ids[0] as $message_id) {
       $message_id .= '>';
 
-      // B) Check for a reply to one of the messages generated by us.
+// B) Check for a reply to one of the messages generated by us.
       $matches = array();
       if (preg_match('/^<(\d+)\.(\d+)@' . $id_right . '>$/', $message_id, $matches)) {
         $cid = $matches[1];
         $nid = $matches[2];
-        // Reply was directly to node.
+// Reply was directly to node.
         if (!$cid) {
-          // Check message id against our records.
+// Check message id against our records.
           if (db_query('SELECT 1 FROM {support_ticket} t WHERE t.nid = :t.nid AND t.client = :t.client', array(':t.nid' => $nid, ':t.client' => $client->clid))->fetchField()) {
             $message['nid'] = $nid;
             return TRUE;
           }
         }
-        // Reply was to followup.
+// Reply was to followup.
         else {
-          // Check message id against our records.
+// Check message id against our records.
           if (db_query('SELECT 1 FROM {comment} c INNER JOIN {support_ticket_comment} t ON c.cid = t.cid WHERE c.cid = :c.cid AND c.nid = :c.nid AND t.client = :t.client', array(':c.cid' => $cid, ':c.nid' => $nid, ':t.client' => $client->clid))->fetchField()) {
             $message['nid'] = $nid;
             return TRUE;
@@ -3362,14 +3372,14 @@ function _support_identify_ticket(&$client, &$message) {
         }
       }
 
-      // C) Check for reply to the incoming message that created the ticket.
+// C) Check for reply to the incoming message that created the ticket.
       $nid = db_query("SELECT nid FROM {support_ticket} WHERE message_id = :message_id", array(':message_id' => $message_id))->fetchField();
       if (isset($nid) && is_numeric($nid)) {
         $message['nid'] = $nid;
         return TRUE;
       }
 
-      // D) Check for reply to an incoming message that created a followup.
+// D) Check for reply to an incoming message that created a followup.
       $nid = db_query("SELECT c.nid FROM {support_ticket_comment} j INNER JOIN {comment} c ON j.cid = c.cid WHERE j.message_id = :j.message_id", array(':j.message_id' => $message_id))->fetchField();
       if (isset($nid) && is_numeric($nid)) {
         $message['nid'] = $nid;
@@ -3378,7 +3388,7 @@ function _support_identify_ticket(&$client, &$message) {
     }
   }
 
-  // E) Look for tickets with an identical subject.
+// E) Look for tickets with an identical subject.
   if (!$client->thread_subject) {
     $client->thread_subject = variable_get('support_thread_by_subject', 3);
   }
@@ -3432,7 +3442,7 @@ function _support_autoassign($clid, $uid = 0) {
         $autoassign[$clid] = $uid;
         break;
       default:
-        // no per-client auto-assign, or an invalid auto-assign
+// no per-client auto-assign, or an invalid auto-assign
         $account = array_shift(user_load_multiple(array(), array('name' => trim($name))));
         if (empty($account) || !$account->uid) {
           $assign = variable_get('support_autoassign_ticket', '<nobody>');
@@ -3472,9 +3482,9 @@ function _support_current_client() {
     if (isset($_SESSION['support_client']) && is_numeric($_SESSION['support_client'])) {
       $client = $_SESSION['support_client'];
     } else if (!user_access('can select client')) {
-      // TODO: It should be possible to set a default client.  Perhaps allow
-      // a weight to be assigned to clients -- then we select the heaviest
-      // matching client...?
+// TODO: It should be possible to set a default client.  Perhaps allow
+// a weight to be assigned to clients -- then we select the heaviest
+// matching client...?
       $client = key($clients);
     }
   }
