diff --git a/support-tickets.css b/support-tickets.css
index 8f073ad..6cf4869 100644
--- a/support-tickets.css
+++ b/support-tickets.css
@@ -96,3 +96,19 @@
   font-size: .75em;
 }
 
+table.support {
+  width: 100%;
+}
+
+.support thead th {
+  padding-right: 1em;
+  border-bottom: 3px solid #CCC;  
+}
+
+.support tbody td {
+  padding: 3px;
+}
+
+.support tbody {
+  border-top: 1px solid #CCC;  
+}
diff --git a/support.module b/support.module
index a4dc11f..01ec7c8 100644
--- a/support.module
+++ b/support.module
@@ -827,16 +827,22 @@ function _support_node_insert_update($node) {
       $node->assigned = 0;
     }
   }
-  $update = db_update('support_ticket')->fields(array(
-        'message_id' => isset($node->message_id) ? $node->message_id : '',
-        'state' => $node->state,
-        'priority' => $node->priority,
-        'client' => $node->client,
-        'assigned' => $node->assigned,
-      ))
-      ->condition('nid', $node->nid)
-      ->execute();
-  if ($update == 0) {
+  $exists = db_select('support_ticket', 't')
+          ->fields('t')
+          ->condition('t.nid', $node->nid)
+          ->execute()->rowCount();
+  if ($exists) {
+    db_update('support_ticket')->fields(array(
+          'message_id' => isset($node->message_id) ? $node->message_id : '',
+          'state' => $node->state,
+          'priority' => $node->priority,
+          'client' => $node->client,
+          'assigned' => $node->assigned,
+        ))
+        ->condition('nid', $node->nid)
+        ->execute();
+  }
+  else {
     db_insert('support_ticket')->fields(array(
           'nid' => $node->nid,
           'message_id' => isset($node->message_id) ? $node->message_id : '',
@@ -1473,9 +1479,9 @@ function _support_mail_text_default($key) {
     'ticket_deny_subject' => 'Support ticket creation denied',
     'ticket_deny_body' => "System message\n\nYou have tried to create a support ticket on the!site site. The creation of the ticket has been cancelled since the e-mail address you sent the message from is not registered at our site.\n\nYou have to be a registered user to be able to create support tickets via mail.\n\nYour feedback is important to us so please register at!uri_login and try again.\n\n!site Team",
     'ticket_new_subject' => '!key !ticket_subject',
-    'ticket_new_body' => "!update_username has created the ticket '!ticket_subject':\n!ticket_url\n\nState:!state\nPriority:!priority\n\n!reply:\n!update_url\n\nTicket text:\n------------------------------\n!ticket_body------------------------------\n\nUnsubscribe from this ticket:\n!unsubscribe_ticket\n\nUnsubscribe from all tickets:\n!unsubscribe_all",
+    'ticket_new_body' => "!update_username has created the ticket '!ticket_subject':\n!ticket_url\n\nState:!state\nPriority:!priority\n\n!reply:\n!update_url\n\nTicket text:\n------------------------------\n!ticket_body\n------------------------------\n\nUnsubscribe from this ticket:\n!unsubscribe_ticket\n\nUnsubscribe from all tickets:\n!unsubscribe_all",
     'ticket_comment_new_subject' => '!key !ticket_subject',
-    'ticket_comment_new_body' => "!update_username has updated the ticket '!ticket_subject':\n!ticket_url\n\nState:!state\nPriority:!priority\n\n!reply:\n!update_url\n\nUpdate text:\n------------------------------\n!update------------------------------\n\nUnsubscribe from this ticket:\n!unsubscribe_ticket\n\nUnsubscribe from all tickets:\n!unsubscribe_all",
+    'ticket_comment_new_body' => "!update_username has updated the ticket '!ticket_subject':\n!ticket_url\n\nState:!state\nPriority:!priority\n\n!reply:\n!update_url\n\nUpdate text:\n------------------------------\n!update\n------------------------------\n\nUnsubscribe from this ticket:\n!unsubscribe_ticket\n\nUnsubscribe from all tickets:\n!unsubscribe_all",
   );
   drupal_alter('support_mail_text_default', $info);
   if (isset($key)) {
@@ -2279,7 +2285,7 @@ function support_status_form(&$form_state, $edit, $title) {
     $node->assigned = $autoassign;
   }
   if ($cid) {
-    $comment = db_query('SELECT state, priority FROM {support_ticket_comment} WHERE cid = :cid', array(':cid' => $cid))->execute()->fetchObject();
+    $comment = db_select('support_ticket_comment','c')->condition('c.cid',$cid)->fields('c')->execute()->fetchObject();
     if ($comment->state && $comment->priority) {
       $node->state = $comment->state;
       $node->priority = $comment->priority;
diff --git a/support.user.inc b/support.user.inc
index 8cd4e92..64ee3f9 100644
--- a/support.user.inc
+++ b/support.user.inc
@@ -67,11 +67,11 @@ function support_page_user($user, $assigned = FALSE, $state = NULL) {
     $query->join('users', 'u', 'u.uid = n.uid');
     $query->leftjoin('comment', 'c', 'c.nid = n.nid');
     $query->condition(db_or()
-      ->condition('c.status', COMMENT_PUBLISHED)
-      ->isNull('c.status'))
-      ->condition('n.status', NODE_PUBLISHED)
-      ->condition('n.type', 'support_ticket')
-      ->condition('t.client', $clients);
+            ->condition('c.status', COMMENT_PUBLISHED)
+            ->isNull('c.status'))
+        ->condition('n.status', NODE_PUBLISHED)
+        ->condition('n.type', 'support_ticket')
+        ->condition('t.client', $clients);
 
     if ($state < 0) {
       $states = _support_get_state(SUPPORT_STATE_CLOSED);
@@ -112,11 +112,12 @@ function support_page_user($user, $assigned = FALSE, $state = NULL) {
         break;
     }
 
-    $query->fields('n', array('nid',' title', 'type', 'changed', 'uid'))
-      ->fields('u', array('name'))
-      ->fields('s', array('comment_count'))
-      ->fields('t', array('client',' state', 'priority', 'assigned'))
-      ->addExpression('GREATEST(n.changed, s.last_comment_timestamp)', 'last_updated');
+    $query->fields('n', array('nid', ' title', 'type', 'changed', 'uid'))
+        ->fields('u', array('name'))
+        ->fields('s', array('comment_count'))
+        ->fields('t', array('client', ' state', 'priority', 'assigned'))
+        ->distinct()
+        ->addExpression('GREATEST(n.changed, s.last_comment_timestamp)', 'last_updated');
 
     $result = $query->execute();
   }
@@ -172,9 +173,9 @@ function support_page_user($user, $assigned = FALSE, $state = NULL) {
 
   if (count($rows) == 0)
     $rows[] = array(array(
-      'data' => t('No tickets available.'),
-      'colspan' => count($header),
-    ));
+        'data' => t('No tickets available.'),
+        'colspan' => count($header),
+        ));
 
   return theme('support_page_user', array('header' => $header, 'rows' => $rows, 'attributes' => array('class' => array('support'))));
 }
