diff --git a/README.txt b/README.txt
index 90c494b..58f233b 100644
--- a/README.txt
+++ b/README.txt
@@ -20,12 +20,12 @@ The module contain an example module which demonstrate how this module can be us
   );
 
   //Draw it.
-  draw_chart($settings); 
+  google_chart_tools_draw_chart($settings); 
 
 * The 'containterId' is optional and if it's not set the 'containerId' will be taken from chart ID ($settings['chart']['chart_id']).
 * The 'options' are optional as well.
 
-* The draw_chart() function returns an array which contains:
+* The google_chart_tools_draw_chart() function returns an array which contains:
   'title' - Title of the chart, 
   'id' - the chart ID, 
   'weight' - A weight can be add to the chart array (default to 0),
diff --git a/analytics_dashboard/analytics_dashboard.admin.inc b/analytics_dashboard/analytics_dashboard.admin.inc
index c339e5b..55bfede 100644
--- a/analytics_dashboard/analytics_dashboard.admin.inc
+++ b/analytics_dashboard/analytics_dashboard.admin.inc
@@ -18,7 +18,7 @@ function analytics_dashboard_admin_settings($form, &$form_state) {
 
   // Generate default charts selection
   $default = variable_get('chart_visible', array());
-  
+
   $form['display'] = array(
     '#type' => 'fieldset',
     '#title' => t('Display settings'),
@@ -32,6 +32,6 @@ function analytics_dashboard_admin_settings($form, &$form_state) {
     '#options' => $options,
     '#description' => t('The checked charts will be shown on the analytics page.'),
   );
-  
+
   return system_settings_form($form);
 }
\ No newline at end of file
diff --git a/analytics_dashboard/analytics_dashboard.api.php b/analytics_dashboard/analytics_dashboard.api.php
index 0004737..088e30a 100644
--- a/analytics_dashboard/analytics_dashboard.api.php
+++ b/analytics_dashboard/analytics_dashboard.api.php
@@ -17,27 +17,27 @@ function hook_analytics_dashboard() {
     $query->condition('ti.tid', $term->tid, '=')
           ->fields('ti', array('nid'));
     $terms[] = $query->countQuery()->execute()->fetchField();
-    
+
   }
   $columns = array('Ideas in category');
   $rows = array($terms);
-  
+
   $settings = array();
-  $settings['chart']['chartCategory'] = array(  
+  $settings['chart']['chartCategory'] = array(
     'header' => $header,
     'rows' => $rows,
     'columns' => $columns,
-    'weight' => -10,  
+    'weight' => -10,
     'chartType' => 'PieChart',
-    'options' => array( 
-      'curveType' => "function", 
-      'is3D' => TRUE,  
+    'options' => array(
+      'curveType' => "function",
+      'is3D' => TRUE,
       'forceIFrame' => FALSE,
       'title' => 'Ideas per category',
       'width' => 500,
-      'height' => 300  
-    )   
+      'height' => 300
+    )
   );
-  
-  return draw_chart($settings);  
+
+  return google_chart_tools_draw_chart($settings);
 }
\ No newline at end of file
diff --git a/analytics_dashboard/analytics_dashboard.charts.inc b/analytics_dashboard/analytics_dashboard.charts.inc
index c8010f2..63314c9 100644
--- a/analytics_dashboard/analytics_dashboard.charts.inc
+++ b/analytics_dashboard/analytics_dashboard.charts.inc
@@ -20,8 +20,7 @@ function analytics_dashboard_charts() {
       $header[$i] = date('d.m.y', $f);
       // The number of nodes created each day.
       $nodes[$i] = db_query("SELECT COUNT(*) FROM {node} WHERE FROM_UNIXTIME(created,'%d.%m.%y') = :dete", array(':dete' => $header[$i]))->fetchField();
-
-      $i ++;
+      $i++;
       $f = strtotime("+1 day", $f);
     }
     // Building the rows, array of the data point arrays.
@@ -29,27 +28,27 @@ function analytics_dashboard_charts() {
     // The labels for the rows.
     $columns = array('No. Of Contents');
 
-    // Put all the data into the settings array, 
+    // Put all the data into the settings array,
     // which will be send to draw.
 
     // Must empty the array first.
     $settings = array();
-    $settings['chart']['chartNodes'] = array(  
+    $settings['chart']['chartNodes'] = array(
       'header' => $header,
       'rows' => $rows,
       'columns' => $columns,
-      'chartType' => GOOGLE_CHART_TOOLS_DEFAULT_CHART,// LineChart, PieChart, ,ColumnChart, ,AreaChart, Gauge, BarChart, etc....
+      'chartType' => GOOGLE_CHART_TOOLS_DEFAULT_CHART,
       'options' => array( // Optionals.
         'curveType' => "function",
-        'forceIFrame' => FALSE,  
+        'forceIFrame' => FALSE,
         'title' => 'Content created per day',
         'width' => 500,
-        'height' => 300  
-      )   
+        'height' => 300
+      )
     );
 
     //Draw it.
-    $ret[] = draw_chart($settings);
+    $ret[] = google_chart_tools_draw_chart($settings);
   }
   //=====================================
   // Chart for comments created per day.
@@ -63,8 +62,7 @@ function analytics_dashboard_charts() {
       // The number of comments created each day.
       $comments[$i] = db_query("SELECT COUNT(*) FROM {comment} WHERE FROM_UNIXTIME(created,'%d.%m.%y') = :dete", array(':dete' => $header[$i]))->fetchField();
       // The number of voted placed each day.
-
-      $i ++;
+      $i++;
       $f = strtotime("+1 day", $f);
     }
     // Building the rows, array of the data point arrays.
@@ -72,28 +70,27 @@ function analytics_dashboard_charts() {
     // The labels for the rows.
     $columns = array('No. Of Comments');
 
-    // Put all the data into the settings array, 
+    // Put all the data into the settings array,
     // which will be send to draw.
-
     // Must empty the array first.
     $settings = array();
-    $settings['chart']['chartComments'] = array(  
+    $settings['chart']['chartComments'] = array(
       'header' => $header,
       'rows' => $rows,
       'columns' => $columns,
-      'chartType' => GOOGLE_CHART_TOOLS_DEFAULT_CHART,// LineChart, PieChart, ,ColumnChart, ,AreaChart, Gauge, BarChart, etc....
+      'chartType' => GOOGLE_CHART_TOOLS_DEFAULT_CHART,
       'options' => array( // Optionals.
         'curveType' => "function",
-        'colors' => array('green'),   
-        'forceIFrame' => FALSE,  
+        'colors' => array('green'),
+        'forceIFrame' => FALSE,
         'title' => 'Comments created per day',
         'width' => 500,
-        'height' => 300  
-      )   
+        'height' => 300
+      )
     );
 
-    //Draw it.
-    $ret[] = draw_chart($settings);
+    // Draw it.
+    $ret[] = google_chart_tools_draw_chart($settings);
   }
   //=====================================
   // Chart for votes placed per day.
@@ -106,8 +103,7 @@ function analytics_dashboard_charts() {
       $header[$i] = date('d.m.y', $f);
       // The number of voted placed each day.
       $votes[$i] = db_query("SELECT COUNT(*) FROM {votingapi_vote} WHERE  FROM_UNIXTIME(timestamp,'%d.%m.%y') = :dete", array(':dete' => $header[$i]))->fetchField();
-
-      $i ++;
+      $i++;
       $f = strtotime("+1 day", $f);
     }
     // Building the rows, array of the data point arrays.
@@ -115,28 +111,28 @@ function analytics_dashboard_charts() {
     // The labels for the rows.
     $columns = array('No. Of Votes');
 
-    // Put all the data into the settings array, 
+    // Put all the data into the settings array,
     // which will be send to draw.
 
     // Must empty the array first.
     $settings = array();
-    $settings['chart']['chartVotes'] = array(  
+    $settings['chart']['chartVotes'] = array(
       'header' => $header,
       'rows' => $rows,
       'columns' => $columns,
-      'chartType' => GOOGLE_CHART_TOOLS_DEFAULT_CHART,// LineChart, PieChart, ,ColumnChart, ,AreaChart, Gauge, BarChart, etc....
+      'chartType' => GOOGLE_CHART_TOOLS_DEFAULT_CHART,
       'options' => array( // Optionals.
         'curveType' => "function",
-        'colors' => array('purple'),   
-        'forceIFrame' => FALSE,  
+        'colors' => array('purple'),
+        'forceIFrame' => FALSE,
         'title' => 'Votes placed per day',
         'width' => 500,
-        'height' => 300  
-      )   
+        'height' => 300
+      )
     );
 
-    //Draw it.
-    $ret[] = draw_chart($settings);  
+    // Draw it.
+    $ret[] = google_chart_tools_draw_chart($settings);
   }
   //=====================================
   // Chart for user joind per day.
@@ -149,8 +145,7 @@ function analytics_dashboard_charts() {
       $header[$i] = date('d.m.y', $f);
       // The number of users join each day.
       $users[$i] = db_query("SELECT COUNT(*) FROM {users} WHERE  FROM_UNIXTIME(created,'%d.%m.%y') = :dete", array(':dete' => $header[$i]))->fetchField();
-
-      $i ++;
+      $i++;
       $f = strtotime("+1 day", $f);
     }
     // Building the rows, array of the data point arrays.
@@ -158,28 +153,28 @@ function analytics_dashboard_charts() {
     // The labels for the rows.
     $columns = array('No. Of Users');
 
-    // Put all the data into the settings array, 
+    // Put all the data into the settings array,
     // which will be send to draw.
 
     // Must empty the array first.
     $settings = array();
-    $settings['chart']['chartUsers'] = array(  
+    $settings['chart']['chartUsers'] = array(
       'header' => $header,
       'rows' => $rows,
       'columns' => $columns,
-      'chartType' => GOOGLE_CHART_TOOLS_DEFAULT_CHART,// LineChart, PieChart, ,ColumnChart, ,AreaChart, Gauge, BarChart, etc....
+      'chartType' => GOOGLE_CHART_TOOLS_DEFAULT_CHART,
       'options' => array( // Optionals.
         'curveType' => "function",
-        'colors' => array('orange'),   
-        'forceIFrame' => FALSE,  
+        'colors' => array('orange'),
+        'forceIFrame' => FALSE,
         'title' => 'Users joined per day',
         'width' => 500,
-        'height' => 300  
-      )   
+        'height' => 300
+      )
     );
 
-    //Draw it.
-    $ret[] = draw_chart($settings); 
+    // Draw it.
+    $ret[] = google_chart_tools_draw_chart($settings);
   }
   //=====================================
   // Chart for content by tags.
@@ -194,30 +189,27 @@ function analytics_dashboard_charts() {
       $query->condition('ti.tid', $term->tid, '=')
             ->fields('ti', array('nid'));
       $terms[] = $query->countQuery()->execute()->fetchField();
-
     }
     $columns = array('Content by Tags');
     $rows = isset($terms) ? array($terms) : array();
 
     $settings = array();
-    $settings['chart']['chartTag'] = array(  
+    $settings['chart']['chartTag'] = array(
       'header' => $header,
       'rows' => $rows,
       'columns' => $columns,
-      'chartType' => 'PieChart',// LineChart, PieChart, ,ColumnChart, ,AreaChart, Gauge, BarChart, etc....
+      'chartType' => 'PieChart',
       'options' => array( // Optionals.
-        'curveType' => "function", 
-        'is3D' => TRUE,  
+        'curveType' => "function",
+        'is3D' => TRUE,
         'forceIFrame' => FALSE,
         'title' => 'Content by Tags',
         'width' => 500,
-        'height' => 300  
-      )   
+        'height' => 300
+      )
     );
-
-    //Draw it.
-    $ret[] = draw_chart($settings);  
+    // Draw it.
+    $ret[] = google_chart_tools_draw_chart($settings);
   }
-  
   return $ret;
 }
\ No newline at end of file
diff --git a/analytics_dashboard/analytics_dashboard.forms.inc b/analytics_dashboard/analytics_dashboard.forms.inc
index c7bc5c1..d113b86 100644
--- a/analytics_dashboard/analytics_dashboard.forms.inc
+++ b/analytics_dashboard/analytics_dashboard.forms.inc
@@ -4,21 +4,19 @@
  * Provides the filtering form on the analytics dashboard page.
  */
 
-
 /**
  * Provide a simple form to change time periods
  */
 function analytics_dashboard_form() {
   $form = array();
-  
+
   // Load some javascript for datepicker
   drupal_add_library('system', 'ui.datepicker');
   drupal_add_js('jQuery(document).ready(function(){jQuery( ".pickadate" ).datepicker({
       dateFormat: "dd.mm.yy",
       autoSize: true
-    });});', 'inline'); 
+    });});', 'inline');
 
-  
   $period_options = array(
     '1_week' => t('1 week'),
     '2_weeks' => t('2 weeks'),
@@ -52,14 +50,14 @@ function analytics_dashboard_form() {
   $form['custom_from'] = array(
     '#type' => 'textfield',
     '#size' => 10,
-    '#attributes' => array('class' => array('pickadate')),  
+    '#attributes' => array('class' => array('pickadate')),
     '#default_value' => isset($_GET['from']) ? filter_xss($_GET['from']) : '',
   );
 
   $form['custom_to'] = array(
     '#type' => 'textfield',
     '#size' => 10,
-    '#attributes' => array('class' => array('pickadate')),  
+    '#attributes' => array('class' => array('pickadate')),
     '#default_value' => isset($_GET['to']) ? filter_xss($_GET['to']) : '',
   );
 
diff --git a/analytics_dashboard/analytics_dashboard.install b/analytics_dashboard/analytics_dashboard.install
index ee3cfe5..10ce15b 100644
--- a/analytics_dashboard/analytics_dashboard.install
+++ b/analytics_dashboard/analytics_dashboard.install
@@ -1,5 +1,9 @@
 <?php
 /**
+ * @file
+ * Install routine for dashboard
+ */
+/**
  * Implements hook_install().
  */
 function analytics_dashboard_install() {
diff --git a/analytics_dashboard/analytics_dashboard.module b/analytics_dashboard/analytics_dashboard.module
index 56aa110..201d834 100644
--- a/analytics_dashboard/analytics_dashboard.module
+++ b/analytics_dashboard/analytics_dashboard.module
@@ -4,13 +4,13 @@
  */
 function analytics_dashboard_menu() {
   $items = array();
-  
+
   $items['admin/reports/analytics-dashboard'] = array(
     'title' => 'Analytics',
     'access arguments' => array('view analytics dashboard'),
     'page callback' => 'analytics_dashboard_page',
   );
-  
+
   // Settings page
   $items['admin/config/analytics-dashboard'] = array(
     'title' => 'Analytics dashboard configuration',
@@ -22,7 +22,6 @@ function analytics_dashboard_menu() {
     'file' => 'analytics_dashboard.admin.inc',
   );
 
-  
   return $items;
 }
 
@@ -32,11 +31,11 @@ function analytics_dashboard_menu() {
 function analytics_dashboard_permission() {
   return array(
     'administer analytics dashboard' => array(
-      'title' => t('Administer Analytics dashboard'), 
+      'title' => t('Administer Analytics dashboard'),
       'description' => t('Perform administration tasks for Analytics dashboard.'),
     ),
     'view analytics dashboard' => array(
-      'title' => t('View Analytics Dashboard'), 
+      'title' => t('View Analytics Dashboard'),
       'description' => t('View analytics dashboard.'),
     ),
   );
@@ -63,7 +62,7 @@ function analytics_dashboard_page() {
   $form = drupal_render($form);
   $charts = analytics_dashboard_get_charts();
   $visibles = variable_get('chart_visible', array());
-  $ret = $form; 
+  $ret = $form;
   $ret .= '<div id="charts">';
   foreach ($charts as $chart) {
     if (in_array($chart['id'], $visibles, TRUE)) {
diff --git a/google_chart_tools.api.php b/google_chart_tools.api.php
index 600eb96..a436a40 100644
--- a/google_chart_tools.api.php
+++ b/google_chart_tools.api.php
@@ -16,7 +16,7 @@ function hook_draw_chart_alter(&$settings) {
       $header = array();
       foreach ($tree as $term) {
         // Feeds the header with terms names.
-        $header[] = $term->name; 
+        $header[] = $term->name;
         $query = db_select('taxonomy_index', 'ti');
         $query->condition('ti.tid', $term->tid, '=')
               ->fields('ti', array('nid'));
@@ -25,12 +25,10 @@ function hook_draw_chart_alter(&$settings) {
       }
       $columns = array('Content per category');
       $rows = array($terms);
-      
       // Replacing the data of the chart.
       $chart['chart']['chartCategory']['header'] = $header;
       $chart['chart']['chartCategory']['rows'] = $rows;
       $chart['chart']['chartCategory']['columns'] = $columns;
-      
       // Adding a colors attribute to the pie.
       $chart['chart']['chartCategory']['options']['colors'] = array('red', '#004411');
     }
diff --git a/google_chart_tools.js b/google_chart_tools.js
index 1a3a5f9..681072b 100644
--- a/google_chart_tools.js
+++ b/google_chart_tools.js
@@ -10,7 +10,7 @@ google.load("visualization", "1", {packages:["corechart", "gauge", "orgchart"]})
   Drupal.behaviors.googleChart = {
     attach: function(context, settings) {
       google.setOnLoadCallback(drawChart);
-      // Callback that creates and populates a data table, 
+      // Callback that creates and populates a data table,
       // instantiates the chart, passes in the data and
       // draws it.
       function drawChart() {
@@ -18,8 +18,7 @@ google.load("visualization", "1", {packages:["corechart", "gauge", "orgchart"]})
         for (var chartId in settings.chart) {
           // Create the data table.
           var data = new google.visualization.DataTable();
-          
-          //OrgChart charts need a different format data table.
+          // OrgChart charts need a different format data table.
           if (settings.chart[chartId].chartType == "OrgChart") {
             data.addColumn('string', 'Title');
             data.addColumn('string', 'Parent');
diff --git a/google_chart_tools.module b/google_chart_tools.module
index 7e53a1f..bc22b3f 100644
--- a/google_chart_tools.module
+++ b/google_chart_tools.module
@@ -3,20 +3,21 @@
 define("GOOGLE_CHART_TOOLS_DEFAULT_CHART", "LineChart");
 
 /**
- * Implements hook_init(). 
+ * Implements hook_init().
  */
 function google_chart_tools_init() {
-  drupal_add_js('https://www.google.com/jsapi', 'external');  
+  drupal_add_js('https://www.google.com/jsapi', 'external');
 }
+
 /**
  * Draw the chart
  */
-function draw_chart($settings) {
+function google_chart_tools_draw_chart($settings) {
   drupal_alter('draw_chart', $settings);
   foreach ($settings['chart'] as $id => $chart) {
     if (!isset($settings['chart'][$id]['containerId'])) {
-      $settings['chart'][$id]['containerId'] = strtolower(str_replace(" ", "-", $id));
-    }   
+      $settings['chart'][$id]['containerId'] = drupal_strtolower(str_replace(" ", "-", $id));
+    }
   }
   drupal_add_css(drupal_get_path('module', 'google_chart_tools') . '/google_chart_tools.css');
   drupal_add_js(drupal_get_path('module', 'google_chart_tools') . '/google_chart_tools.js');
diff --git a/google_chart_tools_example/google_chart_tools_example.module b/google_chart_tools_example/google_chart_tools_example.module
index d462b70..d4be158 100644
--- a/google_chart_tools_example/google_chart_tools_example.module
+++ b/google_chart_tools_example/google_chart_tools_example.module
@@ -5,13 +5,13 @@
  */
 function google_chart_tools_example_menu() {
   $items = array();
-  
+
   $items['reports/site-analytics'] = array(
     'title' => 'Site Analytics',
     'access arguments' => array('access content'),
     'page callback' => 'google_chart_tools_page',
   );
-  
+
   return $items;
 }
 
@@ -25,43 +25,43 @@ function google_chart_tools_page() {
   $i = 0;
   while ($from <= $to) {
     // Building the header - list of date from today backward.
-    $header[$i]   = date('d.m.y', strtotime("-{$i} day"));
+    $header[$i] = date('d.m.y', strtotime("-{$i} day"));
     // The number of nodes created each day.
-    $nodes[$i]     = db_query("SELECT COUNT(*) FROM {node} WHERE  FROM_UNIXTIME(created,'%d.%m.%y') = :dete", array(':dete' => $header[$i]))->fetchField();
+    $nodes[$i] = db_query("SELECT COUNT(*) FROM {node} WHERE  FROM_UNIXTIME(created,'%d.%m.%y') = :dete", array(':dete' => $header[$i]))->fetchField();
     // The number of comments created each day.
-    $comments[$i]  = db_query("SELECT COUNT(*) FROM {comment} WHERE  FROM_UNIXTIME(created,'%d.%m.%y') = :dete", array(':dete' => $header[$i]))->fetchField();
+    $comments[$i] = db_query("SELECT COUNT(*) FROM {comment} WHERE  FROM_UNIXTIME(created,'%d.%m.%y') = :dete", array(':dete' => $header[$i]))->fetchField();
     // The number of voted placed each day.
-    $votes[$i]     = module_exists('votingapi') ? db_query("SELECT COUNT(*) FROM {votingapi_vote} WHERE  FROM_UNIXTIME(timestamp,'%d.%m.%y') = :dete", array(':dete' => $header[$i]))->fetchField() : 0;
+    $votes[$i] = module_exists('votingapi') ? db_query("SELECT COUNT(*) FROM {votingapi_vote} WHERE  FROM_UNIXTIME(timestamp,'%d.%m.%y') = :dete", array(':dete' => $header[$i]))->fetchField() : 0;
     // The number of users join each day.
-    $users[$i]     = db_query("SELECT COUNT(*) FROM {users} WHERE  FROM_UNIXTIME(created,'%d.%m.%y') = :dete", array(':dete' => $header[$i]))->fetchField();
+    $users[$i] = db_query("SELECT COUNT(*) FROM {users} WHERE  FROM_UNIXTIME(created,'%d.%m.%y') = :dete", array(':dete' => $header[$i]))->fetchField();
 
-    $i ++;
+    $i++;
     $from = strtotime("+1 day", $from);
   }
   // Building the rows, array of the data point arrays.
   $rows = array($nodes, $comments, $votes, $users);
   // The labels for the rows.
   $columns = array('No. Of Nodes', 'No. Of Comments', 'No. Of Votes', 'No. Of Users');
-  
-  // Put all the data into the settings array, 
+
+  // Put all the data into the settings array,
   // which will be send to draw.
   // Must empty the array first.
   $settings = array();
-  $settings['chart']['chartOne'] = array(  
+  $settings['chart']['chartOne'] = array(
     'header' => $header,
     'rows' => $rows,
     'columns' => $columns,
-    'chartType' => GOOGLE_CHART_TOOLS_DEFAULT_CHART,// LineChart, PieChart, ,ColumnChart, ,AreaChart, Gauge, BarChart, etc....
+    'chartType' => GOOGLE_CHART_TOOLS_DEFAULT_CHART,
     'containerId' =>  'line_chart',
     'options' => array( // Optionals.
-      'curveType' => "function", 
-      'forceIFrame' => FALSE, 
+      'curveType' => "function",
+      'forceIFrame' => FALSE,
       'title' => 'Nodes / Comments / Votes / Users per day',
       'width' => 800,
-      'height' => 400  
-    )   
+      'height' => 400
+    )
   );
-   
+
   $tree = array(
     // array(Name, Display Name, Parent, Tooltip, Style, Selected Style)
     array('Grandparent', '<font color="red">Grandparent</font>', '', 'Grandparent Tooltip', '', ''),
@@ -69,7 +69,7 @@ function google_chart_tools_page() {
     array('Child1', '', 'Parent', '', '', ''),
     array('Child2', '', 'Parent', 'Child 2 Tooltip', '', ''),
   );
-  
+
   $settings['chart']['chartTwo'] = array(
     'header' => 'Header',
     'containerId' => 'org_chart',
@@ -82,7 +82,7 @@ function google_chart_tools_page() {
     ),
   );
 
-  //Draw it.
-  draw_chart($settings); 
+  // Draw it.
+  google_chart_tools_draw_chart($settings);
   return '<p>Example line chart:</p><div id="line_chart"></div><p>Example org chart:</p><div id="org_chart" class="org_chart"></div>';
-}
+}
\ No newline at end of file
diff --git a/google_chart_tools_views/views/google_chart_tools_views.views.inc b/google_chart_tools_views/views/google_chart_tools_views.views.inc
index 5d47ce1..5a29746 100644
--- a/google_chart_tools_views/views/google_chart_tools_views.views.inc
+++ b/google_chart_tools_views/views/google_chart_tools_views.views.inc
@@ -21,7 +21,7 @@ function google_chart_tools_views_views_plugins() {
         'uses fields' => TRUE,
         'uses options' => TRUE,
         'uses row plugin' => FALSE,
-        'uses row class' => TRUE,  
+        'uses row class' => TRUE,
       ),
     )
   );
diff --git a/google_chart_tools_views/views/google_chart_tools_views_plugin_style.inc b/google_chart_tools_views/views/google_chart_tools_views_plugin_style.inc
index 78f7f67..507fccc 100644
--- a/google_chart_tools_views/views/google_chart_tools_views_plugin_style.inc
+++ b/google_chart_tools_views/views/google_chart_tools_views_plugin_style.inc
@@ -10,10 +10,10 @@
  * @ingroup views_style_plugins
  */
 class google_chart_tools_views_plugin_style extends views_plugin_style {
-  
-  function option_definition () {
+
+  function option_definition() {
     $options = parent::option_definition();
-    
+
     $options['title'] = array('default' => '');
     $options['type'] = array('default' => GOOGLE_CHART_TOOLS_DEFAULT_CHART);
     $options['width'] = array('default' => 600);
@@ -30,7 +30,7 @@ class google_chart_tools_views_plugin_style extends views_plugin_style {
     parent::options_form($form, $form_state);
 
     // Only allow grouping on the first column.
-    $form['grouping'] = array_slice($form['grouping'], 0 ,1);
+    $form['grouping'] = array_slice($form['grouping'], 0, 1);
     $form['grouping'][0]['field']['#options'] = array_slice($form['grouping'][0]['field']['#options'], 0, 2);
 
     $form['title'] = array(
@@ -57,7 +57,7 @@ class google_chart_tools_views_plugin_style extends views_plugin_style {
       '#title' => t('Type'),
       '#description' => t('Chart type, see <a href="https://google-developers.appspot.com/chart/interactive/docs/gallery">Google Chart Tools gallery</a>.'),
       '#required' => TRUE,
-      '#description' => t('Ex. LineChart, PieChart, ColumnChart, AreaChart, Gauge, BarChart, etc....'),  
+      '#description' => t('Ex. LineChart, PieChart, ColumnChart, AreaChart, Gauge, BarChart, etc....'),
       '#default_value' => $this->options['type'],
     );
     $form['width'] = array(
@@ -75,13 +75,13 @@ class google_chart_tools_views_plugin_style extends views_plugin_style {
       '#size' => 8,
       '#required' => TRUE,
       '#default_value' => $this->options['height'],
-    );   
+    );
     $form['curve'] = array(
       '#type' => 'checkbox',
       '#title' => t('Curve'),
       '#description' => t('Use a curve function'),
       '#default_value' => $this->options['curve'],
-    );   
+    );
     $form['3d'] = array(
       '#type' => 'checkbox',
       '#title' => t('3D'),
@@ -114,7 +114,7 @@ class google_chart_tools_views_plugin_style extends views_plugin_style {
             $item[$row_index][] = $field;
           }
         }
-      } 
+      }
     }
     // Default chart treat.
     else {
@@ -137,62 +137,66 @@ class google_chart_tools_views_plugin_style extends views_plugin_style {
         }
       }
 
-      $item = _flip($item);
+      $item = _google_chart_tools_flip($item);
     }
-    
+
     // Account for grouping field being set.
     if (isset($this->options['grouping'][0])) {
       _google_chart_tools_apply_grouping_conversion($header, $item, $this->options['type']);
     }
-    // more flexible to allow for future option replacement
+    // More flexible to allow for future option replacement.
     $option_substitutions = array('vaxis_title', 'haxis_title', 'title');
-    // Allow the use of view build info substitutions
-    if (count($this->view->build_info['substitutions'])) {
-      $substitutions = $this->view->build_info['substitutions'];
-      // loop through and replace view-tokens
-      foreach ($option_substitutions as $option_name) {
-        $this->options[$option_name] = str_replace(array_keys($substitutions), array_values($substitutions), $this->options[$option_name]);
-      }
+    // Allow the use of view build info substitutions.
+    $tokens = array();
+    if (!empty($this->view->build_info['substitutions'])) {
+      $tokens = $this->view->build_info['substitutions'];
     }
-    else if (count($this->view->argument)) {
-      // check for null substitutions if argument was empty
-      foreach ($option_substitutions as $option_name) {
-        for ($i=1; $i<(count($this->view->argument)+1); $i++) {
-          // replace ! and % to account for both substitution types
-          $this->options[$option_name] = str_replace("!$i", '', $this->options[$option_name]);
-          $this->options[$option_name] = str_replace("%$i", '', $this->options[$option_name]);
-        }
+    $count = 0;
+    foreach ($this->view->display_handler->get_handlers('argument') as $arg => $handler) {
+      $token = '%' . ++$count;
+      if (!isset($tokens[$token])) {
+        $tokens[$token] = '';
       }
+
+      // Use strip tags as there should never be HTML in the title.
+      // However, we need to preserve special characters like " that
+      // were removed by check_plain().
+      $tokens['!' . $count] = isset($this->view->args[$count - 1]) ? strip_tags(decode_entities($this->view->args[$count - 1])) : '';
+    }
+
+    // Loop through and replace view-tokens.
+    foreach ($option_substitutions as $option_name) {
+      $this->options[$option_name] = str_replace(array_keys($tokens), array_values($tokens), $this->options[$option_name]);
     }
-    $settings['chart'][drupal_clean_css_identifier($this->view->name . '-' . $this->display->id)] = array(  
+    $settings['chart'][drupal_clean_css_identifier($this->view->name . '-' . $this->display->id)] = array(
       'header' => !empty($header) ? $header : '',
       'rows' => $item,
       'columns' => !empty($column) ? $column : '',
       'chartType' => $this->options['type'],
       'options' => array(
         'vAxis' => array('title' => $this->options['vaxis_title']),
-        'hAxis' => array('title' => $this->options['haxis_title']),  
+        'hAxis' => array('title' => $this->options['haxis_title']),
         'forceIFrame' => FALSE,
         'curveType' => $this->options['curve'] ? "function" : "none",
         'is3D' => $this->options['3d'],
         'isStacked' => $this->options['isstacked'],
-        'colors' => $this->options['colors'] ? explode(",", str_replace(' ', '', $this->options['colors'])) : NULL,  
+        'colors' => $this->options['colors'] ? explode(",", str_replace(' ', '', $this->options['colors'])) : NULL,
         'title' => $this->options['title'],
         'width' => $this->options['width'],
         'height' => $this->options['height'],
         'allowHtml' => TRUE
-      )   
+      )
     );
 
     if (strpos($_GET['q'], 'admin/structure/views/nojs/preview') === FALSE) {
-       //Draw it.
-      $ret = draw_chart($settings);
+       // Draw it.
+      $ret = google_chart_tools_draw_chart($settings);
       return $ret['markup'];
     }
   }
 }
 
-function _flip($arr) {
+function _google_chart_tools_flip($arr) {
   $out = array();
   foreach ($arr as $key => $subarr) {
     foreach ($subarr as $subkey => $subvalue) {
