diff --git a/vud.install b/vud.install
index b69704b..cd503b3 100644
--- a/vud.install
+++ b/vud.install
@@ -6,6 +6,26 @@
  */
 
 /**
+ * @file
+ * Install, update and uninstall functions for the Vote Up/Down core module.
+ */
+
+/**
+ * Implementation of hook_install().
+ */
+function vud_install() {
+  drupal_install_schema('vud');
+}
+
+/**
+ * Implementation of hook_schema().
+ */
+function vud_schema() {
+  return array();
+}
+
+
+/**
  * Implementation of hook_uninstall().
  */
 function vud_uninstall() {
@@ -24,11 +44,11 @@ function vud_update_6200() {
 
   if (module_exists('updown')) {
     $ret[] = drupal_uninstall_schema('updown');
-    drupal_uninstall_module('updown');
+    drupal_uninstall_modules('updown');
   }
   if (module_exists('updown_node')) {
     $ret[] = drupal_uninstall_schema('updown_node');
-    drupal_uninstall_module('updown_node');
+    drupal_uninstall_modules('updown_node');
   }
 
   return $ret;
diff --git a/vud.module b/vud.module
index d79efef..eb90567 100644
--- a/vud.module
+++ b/vud.module
@@ -4,7 +4,6 @@
  * @file
  * Implements the core voting module on top of Voting API.
  */
-
 module_load_include('inc', 'vud', 'vud.theme');  // Include the theme.inc file.
 
 /**
@@ -28,10 +27,10 @@ function vud_menu() {
     'weight' => -10,
   );
 
-  $items['vote/%/%/%/%/%/%/%'] = array(
+  $items['vote/%/%/%/%/%/%'] = array(
     'title'            => 'Vote',
     'page callback'    => 'vud_vote',
-    'page arguments'   => array(1, 2, 3, 4, 5, 6, 7),
+    'page arguments'   => array(1, 2, 3, 4, 5, 6),
     'access arguments' => array('use vote up/down'),
     'type'             => MENU_CALLBACK,
     'file'             => 'vud.theme.inc',
@@ -72,7 +71,7 @@ function vud_init() {
   // page caching. This will eventually clean up those sessions over time.
   // @todo: remove in a future release when it can be reasonably expected that
   // no more sessions with this variable exist in the wild.
-  $now = time();
+  $now = REQUEST_TIME;
   if (!empty($_SESSION['vud_timestamp'])) {
     unset($_SESSION['vud_timestamp']);
   }
@@ -144,22 +143,30 @@ function vud_user_votes() {
         array('data' => t('Vote')),
         array('data' => t('Date'))
       );
-      $sql = db_rewrite_sql("SELECT n.nid, n.title, v.value, v.timestamp FROM {node} n LEFT JOIN {votingapi_vote} v
-                             ON n.nid = v.entity_id
-                             WHERE v.uid = %d AND v.tag = '%s' AND v.entity_type = 'node' AND n.status = 1
-                             ORDER BY v.timestamp DESC");
-      $result = pager_query($sql, 25, 0, NULL, $account->uid, variable_get('vud_tag', 'vote'));
+	  
+	  $sql = db_select('node', 'n');
+	  $v_alias = $query->join('votingapi_vote', 'v', 'n.nid = v.entity_id');
+	  $query->fields('n', array('nid', 'title'));
+	  $query->fields($v_alias, array('value', 'timestamp'));
+	  $query->condition("{$v_alias}.uid", $account->uid);
+	  $query->condition("{$v_alias}.entity_type", node);
+	  $query->condition("n.status", 1);
+	  $query->orderBy("{$v_alias}.timestamp", 'DESC');
+	  $result = $query->execute();
+	  
+      //$result = pager_query($sql, 25, 0, NULL, $account->uid, variable_get('vud_tag', 'vote'));
+	  
       $rows = array();
-      while ($node = db_fetch_object($result)) {
+      foreach ($result as $node) {
         $rows[] = array(
           l($node->title, 'node/'. $node->nid),
           $node->value,
           t('!time ago', array('!time' => format_interval(time() - $node->timestamp)))
         );
       }
-      drupal_set_title(check_plain($account->name));
-      $output = theme('table', $header, $rows);
-      $output .= theme('pager', NULL, 25);
+      drupal_set_title($account->name);
+      $output = theme('table', array('header'=>$header, 'rows'=>$rows));
+      $output .= theme('pager', array('quantity' => 25));
 
       return $output;
     }
@@ -217,15 +224,12 @@ function vud_denied_vote($js = FALSE, $code=VUD_WIDGET_MESSAGE_ERROR) {
 }
 
 /**
- * Implements hook_ctools_plugin_directory().
+ * Implementation of hook_ctools_plugin_dierctory() to let the system know
+ * we implement widget plugins.
  */
-function vud_ctools_plugin_directory($module, $type) {
-  // Safety: go away if CTools is not at an appropriate version.
-  if (!module_invoke('ctools', 'api_version', VUD_REQUIRED_CTOOLS_API)) {
-    return;
-  }
-  if ($module == 'vud' && $type == 'widgets') {
-    return 'widgets';
+function vud_ctools_plugin_directory($module, $plugin) {
+  if ($module == 'vud') {
+    return $plugin;
   }
 }
 
diff --git a/vud.theme.inc b/vud.theme.inc
index 2ceb978..7708a97 100644
--- a/vud.theme.inc
+++ b/vud.theme.inc
@@ -11,6 +11,20 @@ define('VUD_WIDGET_MESSAGE_DENIED', 1);
 define('VUD_REQUIRED_CTOOLS_API', '2.0-alpha');
 
 /**
+ * Implements hook_ctools_plugin_directory().
+ */
+function og_migrate_ctools_plugin_directory($module, $type) {
+  // Safety: go away if CTools is not at an appropriate version.
+  if (!module_invoke('ctools', 'api_version', VUD_REQUIRED_CTOOLS_API)) {
+    return;
+  }
+  if ($module == 'vud' && $type == 'widgets') {
+    return 'plugins/widgets';
+  }
+}
+
+
+/**
  * Implements hook_ctools_plugin_type().
  */
 function vud_ctools_plugin_type() {
@@ -118,7 +132,7 @@ function vud_pseudo_theming($vote_entity, $template_type, $plugin, &$variables)
   }
 
   // TODO: Remove hardcode.
-  $template_file = $plugin['path'] . '/' . $plugin['widget template'] . $plugin['extension'];
+  $template_file = drupal_get_path('module', 'vud') . '/widgets/' . $plugin['name'] . '/widget.tpl.php';
 
   return $template_file;
 }
@@ -221,8 +235,8 @@ function vud_widget_proxy($variables) {
   }
   $variables['vote_label'] = format_plural($vote_result, 'vote', 'votes');
 
-  $link_up = url("vote/$type/$entity_id/1/$tag/$widget_theme/$token_up/nojs");
-  $link_down = url("vote/$type/$entity_id/-1/$tag/$widget_theme/$token_down/nojs");
+  $link_up = url("vote/$type/$entity_id/1/$tag/$widget_theme/$token_up");
+  $link_down = url("vote/$type/$entity_id/-1/$tag/$widget_theme/$token_down");
   $message_on_deny = variable_get('vud_message_on_deny', FALSE);
   $variables['show_links'] = !$readonly || $message_on_deny;
   $variables['show_up_as_link'] = $variables['show_links'] && ($user_vote <= 0);
@@ -235,8 +249,6 @@ function vud_widget_proxy($variables) {
       ctools_modal_add_js();
       $variables['link_class_up'] .= ' ctools-use-modal';
       $variables['link_class_down'] .= ' ctools-use-modal';
-      // FIXME: Where should $widget_message_code come from?
-      $widget_message_code = VUD_WIDGET_MESSAGE_DENIED;
       $link_up = url(sprintf('vud/nojs/denied/%d', $widget_message_code));
       $link_down = url(sprintf('vud/nojs/denied/%d', $widget_message_code));
     }
@@ -247,8 +259,8 @@ function vud_widget_proxy($variables) {
     }
   }
   else {
-    $variables['link_class_up'] .= ' use-ajax';
-    $variables['link_class_down'] .= ' use-ajax';
+    $variables['link_class_up'] .= ' ctools-use-ajax';
+    $variables['link_class_down'] .= ' ctools-use-ajax';
   }
 
   $variables['link_up'] = $link_up;
@@ -339,7 +351,7 @@ function vud_add_files($type, $plugin) {
 /**
  * Function for the main voting handler with Ajax support.
  */
-function vud_vote($type, $entity_id, $value, $tag, $widget, $token, $ajax = 'ajax') {
+function vud_vote($type, $entity_id, $value, $tag, $widget, $token) {
   if (is_numeric($value) && drupal_valid_token($token, "vote/$type/$entity_id/$value/$tag/$widget", TRUE)) {
     $vote = array();
 
@@ -348,6 +360,7 @@ function vud_vote($type, $entity_id, $value, $tag, $widget, $token, $ajax = 'aja
       'entity_id' => $entity_id,
       'tag' => $tag,
     ) + votingapi_current_user_identifier();
+
     $casted_vote = votingapi_select_single_vote_value($casted_vote_criteria);
 
     // Sanity-check the incoming values.
@@ -385,37 +398,35 @@ function vud_vote($type, $entity_id, $value, $tag, $widget, $token, $ajax = 'aja
     drupal_set_message(t("Oops! There was an error in submitting your vote!"), 'warning');
   }
 
-  if ($ajax == 'ajax') {
+  if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest') {
+    ctools_include('ajax');
     $plugin = vud_widget_get($widget);
-    $commands = array();
 
     if ($function = ctools_plugin_get_function($plugin, 'ajax render')) {
       $commands = $function($type, $entity_id, $value, $tag, $token, $widget);
     }
     else {
-        if (!empty($plugin['widget template'])) {
-        $variables = array(
-          'entity_id' =>$entity_id,
-          'type' => $type,
-          'tag' => $tag,
-          'widget_theme' => $widget,
-        );
-        $commands[] = ajax_command_replace("#widget-$type-$entity_id", theme('vud_widget', $variables));
+      $commands = array();
+      if (!empty($plugin['widget template'])) {
+        $commands[] = ctools_ajax_command_replace("#widget-$type-$entity_id", theme('vud_widget', array(
+			'entity_id'=>$entity_id, 
+			'type'=>$type, 
+			'tag'=>$tag,
+			'widget_message_code'=>$widget)));
       }
 
       if (!empty($plugin['votes template'])) {
-        $variables = array(
-          'entity_id' =>$entity_id,
-          'type' => $type,
-          'tag' => $tag,
-          'widget_theme' => $widget,
-        );
-        $commands[] = ajax_command_replace("#votes-$type-$entity_id", theme('vud_votes', $variables));
+        $commands[] = ctools_ajax_command_replace("#votes-$type-$entity_id", theme('vud_votes', array(
+			'entity_id'=>$entity_id, 
+			'type'=>$type, 
+			'tag'=>$tag,
+			'widget_message_code'=>$widget)));
       }
     }
 
-    print ajax_render($commands);
-    exit;
+    // This is the default set of commands. It can be overridden by an individual
+    // widget if it wants to.
+    ctools_ajax_render($commands);
   }
   else {
     drupal_goto($_SERVER['HTTP_REFERER']);
diff --git a/vud_node/vud_node.module b/vud_node/vud_node.module
index a9c811d..0d2ded4 100644
--- a/vud_node/vud_node.module
+++ b/vud_node/vud_node.module
@@ -42,6 +42,7 @@ function vud_node_menu() {
   $items['admin/config/search/voteupdown/node'] = array(
     'title'            => 'Nodes',
     'description'      => 'Vote Up/Down Node settings',
+	'page callback'    => 'drupal_get_form',
     'page arguments'   => array('vud_node_admin_settings'),
     'access arguments' => array('administer vote up/down on nodes'),
     'weight'           => -10,
@@ -143,13 +144,10 @@ function vud_node_vud_widget_message_codes_alter(&$widget_message_codes) {
  */
 function vud_node_node_view($node, $view_mode, $langcode) {
   // avoid showing the widget in some node builds
-  $exclude_modes = array(
-    NODE_BUILD_PREVIEW,
-    NODE_BUILD_SEARCH_INDEX,
-    NODE_BUILD_SEARCH_RESULT,
-    NODE_BUILD_RSS,
-  );
-  if (in_array($node->build_mode, $exclude_modes)) {
+  if ( !empty($node->in_preview)
+	|| $view_mode == 'search_index'
+	|| $view_mode == 'search_result' 
+	|| $view_mode == 'rss' ) {
     break;
   }
   if (($can_edit=user_access('use vote up/down on nodes')) || user_access('view vote up/down count on nodes')) {
@@ -158,7 +156,7 @@ function vud_node_node_view($node, $view_mode, $langcode) {
     $tag = variable_get('vud_tag', 'vote');
     $widget = variable_get('vud_node_widget', 'plain');
     $vote_on_teaser = (bool)variable_get('vud_node_widget_vote_on_teaser', TRUE);
-    $teaser = $a3;
+    //$teaser = $a3;
 
     $widget_message_code = VUD_WIDGET_MESSAGE_ERROR;
     if (!$can_edit) {
@@ -169,38 +167,55 @@ function vud_node_node_view($node, $view_mode, $langcode) {
     }
 
     if ($node_type) {
-
       switch ($widget_showmode) {
+	//We managed the theme according to the view mode
         case VUD_NODE_DISPLAY_TEASER_ONLY:
-          if ($teaser == 1) {
+          if ($view_mode == 'teaser') {
+	    $variables = array(
+	      'entity_id' => $node->nid,
+	      'type' => 'node',
+	      'tag' => $tag,
+	      'widget_type' => $widget,
+	      'readonly' => !$can_edit,
+	      'widget_message_code' => !$vote_on_teaser || !$can_edit, $widget_message_code,
+	    );
             $node->content['vud_node_widget_display'] = array(
-              '#value' => theme('vud_widget', $node->nid, 'node', $tag, $widget, !$vote_on_teaser || !$can_edit, $widget_message_code),
+              '#markup' => theme('vud_widget', $variables),
               '#weight' => -10,
             );
           }
           break;
         case VUD_NODE_DISPLAY_FULL_ONLY:
-          if ($teaser == 0) {
+          if ($view_mode == 'full') {
             $node->content['vud_node_widget_display'] = array(
-              '#value' => theme('vud_widget', $node->nid, 'node', $tag, $widget, !$can_edit, $widget_message_code),
+	      '#markup' => theme('vud_widget', array(
+	      'entity_id'=>$entity_id, 
+	      'type'=>$type, 
+	      'tag'=>$tag,
+	      'widget_message_code'=>$widget)),
               '#weight' => -10,
             );
           }
           break;
         case VUD_NODE_DISPLAY_BOTH:
-          if ($teaser == 1) {
+          if ($view_mode == 'teaser') {
             $readonly = !$vote_on_teaser || !$can_edit;
           }
           else {
             $readonly = !$can_edit;
           }
           $node->content['vud_node_widget_display'] = array(
-            '#value' => theme('vud_widget', $node->nid, 'node', $tag, $widget, $readonly, $widget_message_code),
+            '#markup' => theme('vud_widget', array(
+	      'entity_id' => $node->nid, 
+	      'type'=>'node',
+	      'tag'=>$tag,
+	      'widget_theme'=>$widget,
+	      'readonly'=>$readonly,
+	      'widget_message_code' => $widget_message_code)),
             '#weight' => -10,
           );
           break;
       }
-
     }
   }
 }
@@ -210,6 +225,7 @@ function vud_node_node_view($node, $view_mode, $langcode) {
  */
 function vud_node_template_suggestions($template_type, $plugin, $entity_id) {
   $node = node_load($entity_id);
+  
   return array(
     $template_type,
     $template_type . '_node',
@@ -232,6 +248,7 @@ function vud_node_tracker() {
     $criteria = array('entity_type' => 'node', 'entity_id' => $node->nid, 'tag' => $tag);
     $votes = votingapi_select_votes($criteria);
     $rows[] = array();
+    
     foreach ($votes as $vote) {
       $account = user_load($vote['uid']);
       $rows[] = array(
@@ -240,10 +257,10 @@ function vud_node_tracker() {
         array('data' => format_date($vote['timestamp'], 'small'), 'class' => 'nowrap')
       );
     }
-    drupal_set_title(check_plain($node->title));
-    $output = theme('table', $header, $rows);
-    $output .= theme('pager', NULL, 30);
-
+    
+    drupal_set_title($node->title);
+    $output = theme('table', array('header' => $header,'rows' => $rows));
+    $output .= theme('pager', array('quantity' => 30));
     return $output;
   }
   else {
@@ -269,24 +286,42 @@ function vud_node_link($type, $object, $teaser = FALSE) {
           break;
         case VUD_NODE_DISPLAY_TEASER_ONLY:
           if (($teaser == 1) && $node_type && $view_vud_node_votes_count) {
+	    $variables = array(
+		'entity_id' => $node->nid,
+		'type'=>$type,
+		'tag'=>$tag,
+		'widget_theme' => $widget_theme);
+	    
             $links['vud_node_votes_count'] = array(
-              'title' => theme('vud_votes', $node->nid, $type, $tag, $widget_theme),
+              'title' => theme('vud_votes', $variables),
               'html'  => TRUE,
             );
           }
           break;
         case VUD_NODE_DISPLAY_FULL_ONLY:
           if (($teaser == 0) && $node_type && $view_vud_node_votes_count) {
+	    $variables = array(
+		'entity_id' => $node->nid,
+		'type'=>$type,
+		'tag'=>$tag,
+		'widget_theme' => $widget_theme);
+		    
             $links['vud_node_votes_count'] = array(
-              'title' => theme('vud_votes', $node->nid, $type, $tag, $widget_theme),
+              'title' => theme('vud_votes', $variables),
               'html'  => TRUE,
             );
           }
           break;
         case VUD_NODE_DISPLAY_BOTH:
           if ($node_type && $view_vud_node_votes_count) {
+	    $variables = array(
+		'entity_id' => $node->nid,
+		'type'=>$type,
+		'tag'=>$tag,
+		'widget_theme' => $widget_theme);
+		    
             $links['vud_node_votes_count'] = array(
-              'title' => theme('vud_votes', $node->nid, $type, $tag, $widget_theme),
+              'title' => theme('vud_votes', $variables),
               'html'  => TRUE,
             );
           }
diff --git a/widgets/updown/updown.inc b/widgets/updown/updown.inc
index 5bcda28..3c63a0b 100644
--- a/widgets/updown/updown.inc
+++ b/widgets/updown/updown.inc
@@ -6,9 +6,11 @@
  */
 
 /**
- * Plugin decleration.
+ * Implementation of hook_vud_widgets(). (Specialized)
  */
-$plugin = array(
-  'title' => t('Default'),
-  'widget template' => 'widget',
-);
+function vud_updown_vud_widgets() {
+  return array(
+    'title' => t('Default'),
+    'widget template' => 'widget',
+  );
+}
