diff --git a/CHANGELOG.txt b/CHANGELOG.txt
index 91a60ed..e495b7e 100644
--- a/CHANGELOG.txt
+++ b/CHANGELOG.txt
@@ -1,4 +1,3 @@
-$Id$
 
 Google Docs Integration 6.x-1.0-BETA4, 2010-11-11
 -------------------------------------------------
diff --git a/README.txt b/README.txt
index 9d6f8e1..f2b6c12 100644
--- a/README.txt
+++ b/README.txt
@@ -1,4 +1,4 @@
-$Id$
+Google Docs integration module
 
 DESCRIPTION
 -----------
diff --git a/google-docs-doclist.tpl.php b/google-docs-doclist.tpl.php
new file mode 100644
index 0000000..47fb568
--- /dev/null
+++ b/google-docs-doclist.tpl.php
@@ -0,0 +1,96 @@
+<?php
+
+/**
+ * @file
+ * The template file.
+ */
+
+  if ($page) {
+    drupal_add_css(drupal_get_path('module', 'google_docs') .'/google_docs.css');
+  }
+  
+  global $base_path;
+  $tpath = drupal_get_path('module', 'google_docs') . "/icons";
+  $ipath = $base_path . $tpath;
+  
+  $items = array();
+
+  if ($page) {
+    $logo = theme('image', array('path' => "{$tpath}/gdocs_text_16.png", 'alt' => t('Google Docs logo'), 'attributes' => array('class' => 'gdocs-text')));
+    $text = t('These documents are hosted on <a href="@gurl">!logo</a> and are not present on this site. Documents authors are therefore not actual users of this site. To edit, view or download any of these documents, you need <strong>your Google account</strong> to be given access to them by one of the document editor.', array('!logo' => $logo, '@gurl' => "http://docs.google.com"));
+    $output =<<< EOHTML
+      <div class="gdocs-heading">
+      <a href="http://docs.google.com"><img class='icon' src='{$ipath}/gdocs_64.png' /></a>{$text}
+      </div>
+EOHTML;
+  }
+  
+  if (!$documents) {
+    $output .= "<p>" . t('No document present.') . "</p>";
+  }
+  else {
+  
+    $icosize = ($page ? '32' : '16');
+    
+    $up_txt = ($page ? t('Updated on') : '');
+    $by_txt = t('by');
+    $h = ($page ? "h3" : "h3");
+    
+    foreach ($documents as $doc) {
+      $date = format_date($doc['updated'], 'small');
+      $edit = l(t('View / Edit'), $doc['links']['edit']);
+      $kind = $doc['categories']['kind'];
+
+      $download = '';
+      if ($page && ($format = google_docs_get_export_formats($kind))) {
+        switch ($kind) {
+          case 'spreadsheet':
+            $base = GOOGLE_DOCS_SPREADSHEET_EXPORT_URI;
+            $idkey = 'key';
+            $more_query = "exportFormat=%f";
+            break;
+
+          case 'drawing':
+            $base = GOOGLE_DOCS_DOCUMENT_EXPORT_URI;
+            $idkey = 'docID';
+            $more_query = "exportFormat=%f";
+            break;
+            
+          case 'pdf':
+            $base = GOOGLE_DOCS_PDF_EXPORT_URI;
+            $idkey = 'id';
+            $more_query = "export=download";
+            break;
+            
+          default:
+            $base = GOOGLE_DOCS_DOCUMENT_EXPORT_URI;
+            $idkey = 'docID';
+            $more_query = "exportFormat=%f&format=%f";
+            break;
+          
+        }
+        $download = '&ndash; ' . t('Download');
+       
+      }
+      
+      $items[] = "<{$h} class='title'><img title='{$kind}' alt='{$kind}' class='gdocs-icon' src=\"{$ipath}/gdoc_{$kind}_{$icosize}.png\"/> {$doc['title']}</{$h}>" . "<p class='metadata'>{$up_txt} {$date} {$by_txt} <strong>{$doc['updatedBy']}</strong> &ndash; {$edit} </p>";
+    }
+    
+    $output .= theme('item_list', array('items' => $items, 'title' => NULL, 'type' => 'ul', 'attributes' => array('class' => 'gdocs-list')));
+    
+    if (!$page) {
+      $ctx = _google_docs_get_context();
+      $output .= "<div class=\"more-link\">" . l(t('Show all'), "google_docs/{$ctx->nid}/doclist") . "</div>";
+    }
+  }
+  
+  if ($page) {
+    $limit = variable_get('gdocs_max_page_results', GOOGLE_DOCS_DEF_PAGE_RESULTS);
+    if ($limit && $total_results > $limit) {
+      $output .= "<p class='gdocs-stats'>" . t('Total !limit documents out of !total listed.', array('!total' => $total_results, '!limit' => $limit)) . "</p>";
+    }
+  }
+  
+  print($output);
+
+
diff --git a/google_docs.info b/google_docs.info
index 19b483a..0434a30 100644
--- a/google_docs.info
+++ b/google_docs.info
@@ -1,7 +1,6 @@
-; $Id$
 name = Google Docs integration
 description = Gives some integration with Google Docs
-core = 6.x
+core = 7.x
 
 ; PHP 5.2 is required for the json_decode function
 php = 5.2
diff --git a/google_docs.install b/google_docs.install
index abd3a5e..a265e83 100644
--- a/google_docs.install
+++ b/google_docs.install
@@ -1,32 +1,10 @@
 <?php
-// $Id$
 
 /**
  * @file
  * Install, update and uninstall functions for the google_docs module.
  */
 
-/**
- * Implementation of hook_install().
- */
-function google_docs_install() {
-  
-  drupal_install_schema('google_docs');
-  
-}
-
-function google_docs_uninstall() {
-  
-  drupal_load('module', 'google_docs');
-  
-  drupal_uninstall_schema('google_docs');
-  
-  variable_del('gdocs_max_block_results');
-  variable_del('gdocs_max_page_results');
-  
-  cache_clear_all(GOOGLE_DOCS_CACHE_PREFIX, 'cache', TRUE);
-}
-
 function google_docs_schema() {
   $schema = array();  
   $schema['google_docs_context'] = array(
diff --git a/google_docs.module b/google_docs.module
index 76d9364..2be7818 100644
--- a/google_docs.module
+++ b/google_docs.module
@@ -1,5 +1,4 @@
 <?php
-// $Id$
 
 /**
  * @file
@@ -8,8 +7,8 @@
 
 define("GOOGLE_DOCS_CLIENTLOGIN_URI",        'https://www.google.com/accounts/ClientLogin');
 
-define("GOOGLE_DOCS_LIST_FEED_URI",          'http://docs.google.com/feeds/documents/private/full');
-define("GOOGLE_DOCS_FOLDER_FEED_URI",        'http://docs.google.com/feeds/folders/private/full');
+define("GOOGLE_DOCS_LIST_FEED_URI",          'https://docs.google.com/feeds/documents/private/full');
+define("GOOGLE_DOCS_FOLDER_FEED_URI",        'https://docs.google.com/feeds/folders/private/full');
 
 # http://code.google.com/apis/documents/docs/2.0/developers_guide_protocol.html#DownloadingDocsAndPresentations
 define("GOOGLE_DOCS_DOCUMENT_EXPORT_URI",    'https://docs.google.com/feeds/download/%ss/Export');
@@ -36,24 +35,18 @@ define("GOOGLE_DOCS_DEF_PAGE_RESULTS",  0);
 /**
  * Implements hook_block().
  */
-function google_docs_block($op = 'list', $delta = "0", $edit = array()) {
-  if ('list' == $op) {
+function google_docs_block_view($delta = "0") {
+  
     $blocks["gdocs_list"]['info'] = t('GDocs - list documents');
     return $blocks;
-  }
-
-  if ('view' == $op) {
-    switch ($delta) {
-      case "gdocs_list":
-        return _google_docs_doclist_block();
+    return _google_docs_doclist_block();
+    
     }
-  }
-}
 
 /**
  * Implements hook_perm().
  */
-function google_docs_perm() {
+function google_docs_permission() {
   return array('access google docs');
 }
 
@@ -165,8 +158,8 @@ function google_docs_doclist_page($context_nid=0) {
   else {
     static $retries = 0;
     /* Token expired? Try to re-login */
-    if ($retries < 3 && $token = _google_docs_acquire_token($ctx->email, $ctx->password, FALSE)) {
-      _google_docs_save_context($context_nid, $ctx->email, $ctx->password, $token);
+    if ($retries < 3 && $token = _google_docs_acquire_token($ctx->email, $ctx->passwd, FALSE)) {
+      _google_docs_save_context($context_nid, $ctx->email, $ctx->passwd, $token);
       /* Recurse
        */
       $retries++;
@@ -181,12 +174,22 @@ function google_docs_doclist_page($context_nid=0) {
   }
 
   /* It handles $items == NULL too */
-  $content = theme('google_docs_doclist', $parsed_response['items'], $parsed_response['total_results'], TRUE);
-  
+  $arr = array('documents' => $parsed_response['items'], 'total_results' => $parsed_response['total_results'], 'page' => TRUE);
+  $th  = 'google_docs_doclist';
+  $content = theme($th, $arr);
   return $content;
 }
 
 /**
+ * Preprocesses single blog block item variables.
+ */
+function template_preprocess_google_docs_doclist(&$item)
+{ 
+  $page=$item['page'];
+  $total_results=$item['total_results'];
+  $documents = $item['documents'];
+}
+/**
  * Parses the JSON response for a GData query
  * 
  * @param $query_type
@@ -312,13 +315,11 @@ function _google_docs_decrypt($enc_string) {
 /**
  * Implements hook_nodeapi().
  */
-function google_docs_nodeapi(&$node, $op, $teaser = NULL, $page = NULL) {
-  switch ($op) {
-    case 'delete':
-      db_query("DELETE FROM {google_docs_context} WHERE nid=%d", $node->nid);
-      break;
+function google_docs_node_type_delete($node) {
+  
+  variable_del($node->nid);  
   }
-}
+
 
 /**
  * Tries to understand if the encryption module is setup with a key file
@@ -326,7 +327,7 @@ function google_docs_nodeapi(&$node, $op, $teaser = NULL, $page = NULL) {
 function _google_docs_encrypt_configured() {
   
   encrypt_initialize();
-
+  
   // Run requirements (include install file first)
   module_load_include('install', 'encrypt', 'encrypt');
   $requirements = encrypt_requirements('runtime');
@@ -495,15 +496,23 @@ function _google_docs_get_context($context_nid = NULL) {
     }
   }
   
-  $rs = db_query("SELECT * FROM {google_docs_context} WHERE nid=%d", $context_nid);
+  $q1 = "SELECT * FROM {google_docs_context} WHERE nid=:q11";
+  $a1 = array('q11' => $context_nid);
+  $rs = db_query($q1, $a1)->fetch();
   
-  if ($context = db_fetch_object($rs)) {
+  //foreach ($rs as $context) {
+  
+  
+  if ($context = $rs) {
     $context->email  = google_docs_decrypt($context->email);
     $context->passwd = google_docs_decrypt($context->passwd);
     $context->token  = google_docs_decrypt($context->token);
+ 
+  
   }
   
   return $context;
+  
 }
 
 /**
@@ -522,6 +531,7 @@ function _google_docs_get_context($context_nid = NULL) {
  *   The context token. if NULL, then the context is only wiped and not saved
  *
  */
+
 function _google_docs_save_context($context_nid, $email, $password, $token=NULL) {
   
   $email    = google_docs_encrypt($email);
@@ -531,7 +541,10 @@ function _google_docs_save_context($context_nid, $email, $password, $token=NULL)
     $token = google_docs_encrypt($token);
   }
 
-  db_query("DELETE FROM {google_docs_context} WHERE nid='%d'", $context_nid);
+  //db_query("DELETE FROM {google_docs_context} WHERE nid='%d'", $context_nid);
+  db_delete('google_docs_context')
+  ->condition('nid', $context_nid)
+  ->execute();
   
   if (!empty($token)) {
     $record = array(
@@ -580,8 +593,10 @@ function _google_docs_doclist_block() {
     
     $parsed_response = _google_docs_parse_response(GOOGLE_DOCS_LIST_FEED_QUERY, $response);
     
-    $content = theme('google_docs_doclist', $parsed_response['items'], $parsed_response['total_results'], FALSE);
-  
+    $arr1 = array('documents' => $parsed_response['items'], 'total_results' => $parsed_response['total_results'], 'page' => FALSE);
+    $th1  = 'google_docs_doclist';
+    $content = theme($th1, $arr1);
+    
     cache_set($cid, $content, 'cache', CACHE_TEMPORARY);
   }
   else {
@@ -762,11 +777,11 @@ function _google_docs_form_partial($scope, $email, $password) {
 /**
  * Implements hook_theme().
  */
-function google_docs_theme($existing, $type, $theme, $path) {
+function google_docs_theme() {
   return array(
     'google_docs_doclist' => array(
       'arguments' => array('documents' => array(), 'total_results' => 0, 'page' => 0),
-      'file'      => 'google_docs.theme.inc'
+      'template'      => 'google-docs-doclist'
     ),
   );
 }
@@ -831,13 +846,17 @@ function google_docs_login($email, $passwd, $service='apps') {
     "service={$service}",
     "source=" . urlencode("Google Clogin Drupal Module"),
   );
-
+    
   $serialized_data = '&' . join('&',$data);
-  
-  $headers = array('Content-type'   => 'application/x-www-form-urlencoded',
-                   'Content-Length' => strlen($serialized_data));
-  
-  $response = drupal_http_request(GOOGLE_DOCS_CLIENTLOGIN_URI, $headers, 'POST', $serialized_data);
+  $header1 = array(
+    'headers' => array('Content-type'   => 'application/x-www-form-urlencoded',
+        'Content-Length' => strlen($serialized_data)),
+      'method' => 'POST',
+      'data' => $serialized_data,
+       );
+    
+    
+  $response = drupal_http_request(GOOGLE_DOCS_CLIENTLOGIN_URI, $header1);
 
   $goog_resp = array();
   foreach (explode("\n", $response->data) as $l) {
@@ -875,6 +894,7 @@ function google_docs_login($email, $passwd, $service='apps') {
  *   An array containing the HTTP code and the response
  *
  */
+
 function google_docs_http_get($url, $token, $params = NULL, $headers = array()) {
   
   $query_params = '';
@@ -887,10 +907,12 @@ function google_docs_http_get($url, $token, $params = NULL, $headers = array())
     $query_params = "?" . join('&', $query_params);
   }
   
-  $headers = array_merge($headers, array("Authorization" => "GoogleLogin auth=\"{$token}\"", "GData-Version" => "2.0"));
+  $headers = array_merge($headers, array("Authorization" => "GoogleLogin auth=\"{$token}\"", "GData-Version" => "2.0" ));
 
-  $response = drupal_http_request($url . $query_params, $headers, 'GET');
+  $arr = array('headers'=> $headers,'method'=>'GET');
+  $response = drupal_http_request($url . $query_params, $arr);
 
   return array($response->code, $response->data);
 }
 
+  
diff --git a/google_docs.theme.inc b/google_docs.theme.inc
deleted file mode 100644
index ed17c86..0000000
--- a/google_docs.theme.inc
+++ /dev/null
@@ -1,100 +0,0 @@
-<?php
-// $Id$
-
-/**
- * @file
- * The google_docs module, theme functions.
- */
-
-function theme_google_docs_doclist($documents, $total_results, $page=FALSE) {
-
-  if ($page) {
-    drupal_add_css(drupal_get_path('module', 'google_docs') .'/google_docs.css');
-  }
-  
-  global $base_path;
-  $tpath = drupal_get_path('module', 'google_docs') . "/icons";
-  $ipath = $base_path . $tpath;
-  
-  $items = array();
-
-  if ($page) {
-    $logo = theme('image', "{$tpath}/gdocs_text_16.png", t('Google Docs logo'), t('Google Docs logo'), array('class' => 'gdocs-text'));
-    $text = t('These documents are hosted on <a href="@gurl">!logo</a> and are not present on this site. Documents authors are therefore not actual users of this site. To edit, view or download any of these documents, you need <strong>your Google account</strong> to be given access to them by one of the document editor.', array('!logo' => $logo, '@gurl' => "http://docs.google.com"));
-    $output =<<< EOHTML
-      <div class="gdocs-heading">
-      <a href="http://docs.google.com"><img class='icon' src='{$ipath}/gdocs_64.png' /></a>{$text}
-      </div>
-EOHTML;
-  }
-  
-  if (!$documents) {
-    $output .= "<p>" . t('No document present.') . "</p>";
-  }
-  else {
-  
-    $icosize = ($page ? '32' : '16');
-    
-    $up_txt = ($page ? t('Updated on') : '');
-    $by_txt = t('by');
-    $h = ($page ? "h3" : "h3");
-    
-    foreach ($documents as $doc) {
-      $date = format_date($doc['updated'], 'small');
-      $edit = l(t('View / Edit'), $doc['links']['edit']);
-      $kind = $doc['categories']['kind'];
-
-      $download = '';
-      if ($page && ($format = google_docs_get_export_formats($kind))) {
-        switch ($kind) {
-          case 'spreadsheet':
-            $base = GOOGLE_DOCS_SPREADSHEET_EXPORT_URI;
-            $idkey = 'key';
-            $more_query = "exportFormat=%f";
-            break;
-
-          case 'drawing':
-            $base = GOOGLE_DOCS_DOCUMENT_EXPORT_URI;
-            $idkey = 'docID';
-            $more_query = "exportFormat=%f";
-            break;
-            
-          case 'pdf':
-            $base = GOOGLE_DOCS_PDF_EXPORT_URI;
-            $idkey = 'id';
-            $more_query = "export=download";
-            break;
-            
-          default:
-            $base = GOOGLE_DOCS_DOCUMENT_EXPORT_URI;
-            $idkey = 'docID';
-            $more_query = "exportFormat=%f&format=%f";
-            break;
-        }
-        $download = '&ndash; ' . t('Download');
-        foreach (google_docs_get_export_formats($kind) as $format) {
-          $expq = str_replace('%f', $format, $more_query);
-          $download .= ' ' . l($format, str_replace('%s', $kind, $base), array('attributes' => array('class' => 'gdocs-download new-window', 'target' => '_blank'), 'query' => "{$idkey}=" . urlencode($doc['id']) . "&{$expq}"));
-        }
-      }
-      
-      $items[] = "<{$h} class='title'><img title='{$kind}' alt='{$kind}' class='gdocs-icon' src=\"{$ipath}/gdoc_{$kind}_{$icosize}.png\"/> {$doc['title']}</{$h}>" . "<p class='metadata'>{$up_txt} {$date} {$by_txt} <strong>{$doc['updatedBy']}</strong> &ndash; {$edit} {$download}</p>";
-    }
-    
-    $output .= theme('item_list', $items, NULL, 'ul', array('class' => 'gdocs-list'));
-    
-    if (!$page) {
-      $ctx = _google_docs_get_context();
-      $output .= "<div class=\"more-link\">" . l(t('Show all'), "google_docs/{$ctx->nid}/doclist") . "</div>";
-    }
-  }
-  
-  if ($page) {
-    $limit = variable_get('gdocs_max_page_results', GOOGLE_DOCS_DEF_PAGE_RESULTS);
-    if ($limit && $total_results > $limit) {
-      $output .= "<p class='gdocs-stats'>" . t('Total !limit documents out of !total listed.', array('!total' => $total_results, '!limit' => $limit)) . "</p>";
-    }
-  }
-  
-  return $output;
-}
