diff --git a/mapstraction.apis.inc b/mapstraction.apis.inc
index 6c6eb07..4ae5544 100644
--- a/mapstraction.apis.inc
+++ b/mapstraction.apis.inc
@@ -1,3 +1,4 @@
+
 <?php
 
 /**
@@ -13,12 +14,12 @@ function mapstraction_basic_render($settings, $api_id) {
   $api = $apis[$api_id];
   
   // Find %key flag in 'src'
-  $src = strtr($api['src'], array('%key' => variable_get('mapstraction_api_'. $api_id, '')));
+  $src = strtr($api['src'], array('%key' => variable_get('mapstraction_api_' . $api_id, '')));
   return '<script type="text/javascript" src="' . $src . '"></script>';
 }
 
 function mapstraction_yahoo_render($settings) {
-  $src = 'http://api.maps.yahoo.com/ajaxymap?v=3.0&appid=' . variable_get('mapstraction_api_'. $api_id, '');
+  $src = 'http://api.maps.yahoo.com/ajaxymap?v=3.0&appid=' . variable_get('mapstraction_api_' . $api_id, '');
   return '<script type="text/javascript" src="' . $src . '"></script>';
 }
 
@@ -34,19 +35,19 @@ function mapstraction_freeearth_render() {
 
 function mapstraction_cloudmade_settings_form($settings) {
   $form = array();
-  
+
   $form['style_id'] = array(
     '#type' => 'textfield',
     '#title' => t('Map Style ID'),
     '#size' => 40,
     '#maxlength' => 255,
     '#default_value' => $settings['style_id'],
-    '#process' => array('views_process_dependency'),
+    '#process' => array('ctools_dependent_process'),
     '#dependency' => array(
       'edit-style-options-api' => array('cloudmade'),
     ),
   );
-  
+
   return $form;
 }
 
@@ -57,19 +58,19 @@ function mapstraction_cloudmade_render($settings, $api_id, $id) {
   $js = '
       $(document).ready(function() {
         var cloudmade = new OpenLayers.Layer.CloudMade("CloudMade", {
-          key: "' . variable_get('mapstraction_api_'. $api_id, '') . '",
+          key: "' . variable_get('mapstraction_api_' . $api_id, '') . '",
           styleId: ' . $settings['style_id'] . ',
         });
         Drupal.mapstraction["' . $id . '"].maps["openlayers"].addLayer(cloudmade);
         Drupal.mapstraction["' . $id . '"].maps["openlayers"].setBaseLayer(cloudmade);
       });';
 
-  drupal_add_js($js, 'inline', 'footer');
-  
+  drupal_add_js($js, array('type' => 'inline', 'scope' => 'footer'));
+
   return $output;
 }
 
 function mapstraction_openlayers_render($settings) {
   $src = 'http://openlayers.org/api/OpenLayers.js';
   return "<script type='text/javascript' src='$src'></script>\n";
-}
\ No newline at end of file
+}
diff --git a/mapstraction.drupal.js b/mapstraction.drupal.js
index 8edc278..25de2cb 100644
--- a/mapstraction.drupal.js
+++ b/mapstraction.drupal.js
@@ -1,39 +1,40 @@
-Drupal.behaviors.mapstraction = function (context) {
-  Drupal.mapstraction = [];
+Drupal.behaviors.mapstraction = {
+  attach: function(context) {
+    Drupal.mapstraction = [];
 
 	// return a MXN lat/long point from a row
-  function preparePoint(row) {
-    return new mxn.LatLonPoint(Number(row.latitude), Number(row.longitude));
-  }
+    function preparePoint(row) {
+      return new mxn.LatLonPoint(Number(row.latitude), Number(row.longitude));
+    }
 
-  // Initialize marker object from a point data
-  function prepareMarker(row, hover) {
-    var markerPoint = preparePoint(row);
-    var marker = new mxn.Marker(markerPoint);
+    // Initialize marker object from a point data
+    function prepareMarker(row, hover) {
+      var markerPoint = preparePoint(row);
+      var marker = new mxn.Marker(markerPoint);
       
       // set info bubble if we have a title
-    if (row.text) {
-      marker.setInfoBubble('<div class="mapstraction-info-window">'+ row.text +'</div>');
-    }
+      if (row.text) {
+        marker.setInfoBubble('<div class="mapstraction-info-window">'+ row.text +'</div>');
+      }
       
       // override default icon if provided
-    if (row.icon) {
-      marker.setIcon(row.icon.url, [row.icon.width, row.icon.height], [row.icon.width/2,row.icon.height]);
-    }
+      if (row.icon) {
+        marker.setIcon(row.icon.url, [row.icon.width, row.icon.height], [row.icon.width/2,row.icon.height]);
+      }
 
       // set all attributes
-    if (row.attributes){
-      $.each(row.attributes, marker.setAttribute);
-    }        
+      if (row.attributes){
+        $.each(row.attributes, marker.setAttribute);
+      }        
 
-    marker.setHover(hover);
+      marker.setHover(hover);
     
-    return marker;
-  }
+      return marker;
+    }
 
 	// generate a polyline to add to a map
-  function preparePolyline(row, points) {
-    var poly = new mxn.Polyline(points);
+        function preparePolyline(row, points) {
+          var poly = new mxn.Polyline(points);
 
 		//Shuffle colors
 		var color = '#';
@@ -46,29 +47,29 @@ Drupal.behaviors.mapstraction = function (context) {
 		poly.opacity = 1;
 		poly.closed = false;
 		return poly;
-  }
+        }
 
 	// add markers and/or polylines to the map
-  function getGroupRenderer(map, behaviours, overlays) {
-    return function(row) {
-      var points = $.map(row.markers, overlays.markers ? 
-        function(point) {
+        function getGroupRenderer(map, behaviours, overlays) {
+          return function(row) {
+            var points = $.map(row.markers, overlays.markers ? 
+            function(point) {
   	      var marker = prepareMarker(point, behaviours.hover);
   	      map.addMarker(marker);
   	      return marker.location;
-        } : preparePoint
-      );
+            } : preparePoint
+            );
 
-      if (overlays.polylines) {
-        var poly = preparePolyline(row, points);
-        map.addPolyline(poly);
-      }
-    };
-  }
+            if (overlays.polylines) {
+              var poly = preparePolyline(row, points);
+              map.addPolyline(poly);
+            }
+          };
+        }
 
 	// Iterate over each map added to the page
-  $(Drupal.settings.mapstraction).each(function() {
-    var map = Drupal.mapstraction[this.mapId] = new mxn.Mapstraction(this.mapId, this.apiName);
+        $(Drupal.settings.mapstraction).each(function() {
+          var map = Drupal.mapstraction[this.mapId] = new mxn.Mapstraction(this.mapId, this.apiName);
 
     // Set up markers and info bubbles.
     $.map(this.markers, getGroupRenderer(map, this.behaviours, this.overlays));
@@ -106,4 +107,5 @@ Drupal.behaviors.mapstraction = function (context) {
       map.setCenterAndZoom(startPoint, Number(this.initialPoint.zoom));
     }
   });
-};
\ No newline at end of file
+ }
+};
diff --git a/mapstraction.info b/mapstraction.info
index 9e2c3fc..22343b3 100644
--- a/mapstraction.info
+++ b/mapstraction.info
@@ -1,4 +1,7 @@
 name = Mapstraction
-core = 6.x
+core = 7.x
 description = Mapstraction allows you to display maps using a number of different mapping APIs.
-dependencies[] = views
\ No newline at end of file
+dependencies[] = views
+files[] = mapstraction.module
+files[] = mapstraction.apis.inc
+files[] = mapstraction_style_map.inc
diff --git a/mapstraction.install b/mapstraction.install
index c94cf9d..8d16e23 100644
--- a/mapstraction.install
+++ b/mapstraction.install
@@ -1,13 +1,12 @@
 <?php
 
 /**
- * Implementaiton of hook_uninstall
+ * Implements hook_uninstall().
  */
-function mapstraction_uninstall(){
-  foreach(mapstraction_apis(TRUE) as $key => $api){
-    if($api['has_key']){
-      variable_del('mapstraction_api_'. $key);
+function mapstraction_uninstall() {
+  foreach (mapstraction_apis(TRUE) as $key => $api) {
+    if ($api['has_key']) {
+      variable_del('mapstraction_api_' . $key);
     }
   }
 }
-?>
\ No newline at end of file
diff --git a/mapstraction.module b/mapstraction.module
index ef1e799..54864a4 100644
--- a/mapstraction.module
+++ b/mapstraction.module
@@ -7,26 +7,26 @@
  */
 
 /**
- * Implementation of hook_theme().
+ * Implements hook_theme().
  */
 function mapstraction_theme($existing, $type, $theme, $path) {
   return array(
     'mapstraction_map' => array(
-      'arguments' => array('api_script' => NULL, 'map_id' => NULL, 'width' => NULL, 'height' => NULL),
-      'template' => 'mapstraction-map',
+      'variables' => array('api_script' => NULL, 'map_id' => NULL, 'width' => NULL, 'height' => NULL),
+      'template'  => 'mapstraction-map',
     ),
-  );  
+  );
 }
 
 /**
- * Implementation of hook_views_api().
+ * Implements hook_views_api().
  */
 function mapstraction_views_api() {
   return array('api' => 2);
 }
 
 /**
- * Implementation of hook_menu().
+ * Implements hook_menu().
  */
 function mapstraction_menu() {
   $items = array();
@@ -43,16 +43,21 @@ function mapstraction_menu() {
 }
 
 /**
- * Implementation of hook_perm().
+ * Implements hook_permission().
  */
-function mapstraction_perm() {
-  return array('administer mapstraction');
+function mapstraction_permission() {
+  return array(
+    'administer mapstraction' => array(
+      'title' => t('Administer Mapstraction module'),
+      'description' => t('Perform administration tasks for mapstraction module.'),
+    ),
+  );
 }
 
 /**
  * Admin settings form
  */
-function mapstraction_admin_settings(){
+function mapstraction_admin_settings() {
   $form = array();
   $form['mapstraction_keys'] = array(
     '#type' => 'fieldset',
@@ -60,13 +65,13 @@ function mapstraction_admin_settings(){
     '#description' => t('Provide API keys for any of the providers below you will be using.'),
     '#collapsible' => FALSE,
   );
-  
-  foreach(mapstraction_apis(TRUE) as $key => $api){
+
+  foreach (mapstraction_apis(TRUE) as $key => $api) {
     if (!empty($api['has_key'])) {
-      $form['mapstraction_keys']['mapstraction_api_'. $key] = array(
+      $form['mapstraction_keys']['mapstraction_api_' . $key] = array(
         '#type' => 'textfield',
         '#title' => $api['title'],
-        '#default_value' => variable_get('mapstraction_api_'. $key, NULL)
+        '#default_value' => variable_get('mapstraction_api_' . $key, NULL)
       );
     }
   }
@@ -75,7 +80,7 @@ function mapstraction_admin_settings(){
 }
 
 /**
- * Implementation of hook_views_plugins().
+ * Implements hook_views_plugins().
  */
 function mapstraction_views_plugins() {
   return array(
@@ -192,13 +197,13 @@ function mapstraction_apis($full = FALSE) {
 function mapstraction_render_map($id, $provider, $settings, $rows = array()) {
   $apis = mapstraction_apis(TRUE);
   $api = $apis[$provider];
-  
+
   // Allow the API definition to override the API name.
   $provider = !empty($api['api']) ? $api['api'] : $provider;
 
   // append unique name space to id
   $mapid = 'mapstraction-' . $id;
-  
+
   module_load_include('inc', 'mapstraction', 'mapstraction.apis');
   $api_script = '';
   if (function_exists($api['render'])) {
@@ -214,14 +219,14 @@ function mapstraction_render_map($id, $provider, $settings, $rows = array()) {
   // load mxn core and provivder specific JS. Not using parameter approach due to drupal_add_js()
   drupal_add_js($library_path . '/mxn.js');
   drupal_add_js($library_path . '/mxn.core.js');
-  drupal_add_js($library_path . '/mxn.'. $provider .'.core.js');
+  drupal_add_js($library_path . '/mxn.' . $provider . '.core.js');
   drupal_add_js(drupal_get_path('module', 'mapstraction') . '/mapstraction.drupal.js');
-  
+
   // allow other modules to alter the rows collection
   if ($altrows = module_invoke_all('mapstraction_rows_alter', $rows, $id, $provider)) {
     $rows = $altrows;
   }
-  
+
   // Center and zoom properly for a single point.
   if (count($rows) == 1 && !empty($rows[0]['markers']) && count($rows[0]['markers']) == 1) {
     // note we're reusing the initial point zoom value if set
@@ -229,7 +234,7 @@ function mapstraction_render_map($id, $provider, $settings, $rows = array()) {
     $settings['initial_point']['auto'] = 0;
     $settings['initial_point']['latitude'] = $rows[0]['markers'][0]['latitude'];
     $settings['initial_point']['longitude'] = $rows[0]['markers'][0]['longitude'];
-  }  
+  }
 
   $map = array(
     'mapId' => $mapid,
@@ -243,14 +248,14 @@ function mapstraction_render_map($id, $provider, $settings, $rows = array()) {
 
   // Add the map to Drupal.settings object in JS.
   drupal_add_js(array('mapstraction' => array($map)), 'setting');
-  
+
   // assume px dimensions if no other measure provided
-  if (is_numeric($settings['width'])){
+  if (is_numeric($settings['width'])) {
     $settings['width'] = $settings['width'] . 'px';
   }
-  if (is_numeric($settings['height'])){
+  if (is_numeric($settings['height'])) {
     $settings['height'] = $settings['height'] . 'px';
   }
-  
-  return theme('mapstraction_map', $api_script, $mapid, $settings['width'], $settings['height']);
+
+  return theme('mapstraction_map', array('api_script' => $api_script, 'map_id' => $mapid, 'width' => $settings['width'], 'height' => $settings['height']));
 }
diff --git a/mapstraction_style_map.inc b/mapstraction_style_map.inc
index a74cbcb..3db8bc3 100644
--- a/mapstraction_style_map.inc
+++ b/mapstraction_style_map.inc
@@ -97,7 +97,7 @@ class mapstraction_style_map extends views_plugin_style {
       '#title' => t('Latitude'),
       '#size' => 40,
       '#maxlength' => 255,
-      '#process' => array('views_process_dependency'),
+      '#process' => array('ctools_dependent_process'),
       '#dependency' => array(
         'edit-style-options-initial-point-auto' => array(0)
       ),
@@ -109,7 +109,7 @@ class mapstraction_style_map extends views_plugin_style {
       '#title' => t('Longitude'),
       '#size' => 40,
       '#maxlength' => 255,
-      '#process' => array('views_process_dependency'),
+      '#process' => array('ctools_dependent_process'),
       '#dependency' => array(
         'edit-style-options-initial-point-auto' => array(0)
       ),
@@ -121,24 +121,24 @@ class mapstraction_style_map extends views_plugin_style {
       '#title' => t('Zoom level'),
       '#size' => 2,
       '#maxlength' => 2,
-      '#process' => array('views_process_dependency'),
+      '#process' => array('ctools_dependent_process'),
       '#dependency' => array(
         'edit-style-options-initial-point-auto' => array(0)
       ),
       '#default_value' => $this->options['initial_point']['zoom'],
     );
-    
+
     $form['initial_point']['zoom_single'] = array(
       '#type' => 'textfield',
       '#title' => t('Single result zoom level'),
       '#size' => 2,
       '#maxlength' => 2,
-      '#process' => array('views_process_dependency'),
+      '#process' => array('ctools_dependent_process'),
       '#dependency' => array(
         'edit-style-options-initial-point-auto' => array(1)
       ),
       '#default_value' => $this->options['initial_point']['zoom_single'],
-    );    
+    );
 
     $form['behaviours'] = array(
       '#type' => 'checkboxes',
@@ -285,7 +285,7 @@ class mapstraction_style_map extends views_plugin_style {
    * Return output that will render the view as a map
    */
   function render() {
-    if (!empty($this->view->preview) && $this->view->preview && $this->view->live_preview) {  
+    if (!empty($this->view->preview) && $this->view->preview && $this->view->live_preview) {
       return '<div class="messages error">Preview is disabled for the Mapstraction style plugin.</div>' . parent::render();
     }
     else {
@@ -296,10 +296,10 @@ class mapstraction_style_map extends views_plugin_style {
         vpr('views_plugin_style_default: Missing row plugin');
         return;
       }
-      
+
       // Group the rows according to the grouping field, if specified.
       $sets = $this->render_grouping($this->view->result, $this->options['grouping']);
-      
+
       $point_groups = array();
       foreach ($sets as $title => $records) {
         $point_groups[] = array(
@@ -323,7 +323,7 @@ class mapstraction_style_map extends views_plugin_style {
   protected function map_points($rows = array()) {
     $points = array();
     $uses_row_plugin = $this->uses_row_plugin();
-    foreach($rows as $row_index => $row) {
+    foreach ($rows as $row_index => $row) {
       //an essential to use row_plugin->render()
       $this->view->row_index = $row_index;
       $point = self::map_point($this->rendered_fields[$row_index], $this->options['fields']);
@@ -353,8 +353,8 @@ class mapstraction_style_map extends views_plugin_style {
 
     foreach ($field_map as $key => $value) {
       // handle fields with more than one value
-      if (is_array($value)){
-        foreach($value as $item){
+      if (is_array($value)) {
+        foreach ($value as $item) {
           if (!empty($item)) {
             $values[$item] = $row[$item];
           }
@@ -378,8 +378,8 @@ class mapstraction_style_map extends views_plugin_style {
    */
   private static function get_icon_field_value($path) {
     $field = array();
-    if (!empty($path)){
-      if (is_file($path)){
+    if (!empty($path)) {
+      if (is_file($path)) {
         list($field['width'], $field['height']) = getimagesize($path);
         $path = (url($path) == $path) ? $path : (base_path() . $path);
       }
