diff --git a/js/live_tweets.js b/js/live_tweets.js
index 1c59fd4..b6e78b0 100755
--- a/js/live_tweets.js
+++ b/js/live_tweets.js
@@ -1,97 +1,113 @@
-var liveTweets = {};
+(function($) {
 
-// Last id fetched
-liveTweets.last = null;
+  /**
+   * Attach behaviors.
+   */
+  Drupal.behaviors.liveTweets = {
+    attach: function(context) {
+      if ($('#block-live-tweets-live-tweets').length) {
+        Drupal.liveTweets.update();
+        setInterval('Drupal.liveTweets.update()', Drupal.settings.live_tweets.refresh);
+      }
+    }
+  };
 
-// Fetch new feeds and display them
-liveTweets.update = function () {
-	var query = "q=" + Drupal.settings.live_tweets.keywords || "Drupal";
-	var ntweets = Drupal.settings.live_tweets.ntweets || 5;
-	if (liveTweets.last) query += "&since_id=" + liveTweets.last;
-	$.ajax({
-		  url: "http://search.twitter.com/search.json",
-		  cache: false,
-		  dataType: "jsonp",
-		  data: "rpp=" + ntweets + "&show_user=true&" + query,
-		  success: function(json){
-			if (!liveTweets.last) { 
-				$('#block-live_tweets-0 .content').empty();
-				$('#block-live_tweets-0').show();
-			}
-			var i;
-			// Append tweets
-			for (i = 0; i < json.results.length; i += 1) {
-				if (liveTweets.last) {
-					var tweets = $('#block-live_tweets-0 .content .tweet');
-					if (tweets.length + 1 > ntweets) $(tweets.eq(tweets.length - 1)).remove();
-					$('#block-live_tweets-0 .content').prepend(
-					'<div class="tweet clearfix">' 
-					+ '<div class="fusion-float-imagefield-left imagecache">' + liveTweets.parseAvatar(json.results[i].profile_image_url) + '</div>'
-					+ '<div id="tweet-text">' + liveTweets.parse(json.results[i].text) + '</div>'
-					+ '<div id="tweet-created">' + liveTweets.parseDate(json.results[i].created_at) + '</div>'
-					+ '</div>');
-				} else $('#block-live_tweets-0 .content').append('<div class="tweet">' + liveTweets.parseAvatar(json.results[i].profile_image_url) + liveTweets.parse(json.results[i].text) + '</div>');
-			}
-			// Store last tweet id
-			if (json.results.length > 0) liveTweets.last = json.results[0].id;
-		  }
-		});
-};
+  Drupal.liveTweets = Drupal.liveTweets || {};
 
-// Parse tweet feeds to create links
-liveTweets.parse = function (text) {
-		// Convert urls to links
-		text = text.replace(/((http|https):\/\/[^ ]*)/g, '<a href="$1" target="_blank">$1</a> ');
-		// @User links
-		text = text.replace(/(^|\s)@(\w+)/g, '$1<a href="http://twitter.com/$2" target="_blank">@$2</a>');
-		// #Search links
-		text = text.replace(/(^|\s)#(\w+)/g, '$1<a href="http://search.twitter.com/search?q=%23$1" target="_blank">#$2</a>');
-		return text
-};
+  // Last id fetched
+  Drupal.liveTweets.last = null;
 
-/**
- * Parse tweet feeds to display avatar
- * 
- */
-liveTweets.parseAvatar = function(profile_image_url) {
-	profile_image_url = '<img src="' + profile_image_url + '"/>';
-	return profile_image_url;
-}
+  // Fetch new feeds and display them
+  Drupal.liveTweets.update = function () {
+    var query = "q=" + Drupal.settings.live_tweets.keywords || "Drupal";
+    var ntweets = Drupal.settings.live_tweets.ntweets || 5;
+    if (Drupal.liveTweets.last) {
+      query += "&since_id=" + Drupal.liveTweets.last;
+    }
+    $.ajax({
+      url: "http://search.twitter.com/search.json",
+      cache: false,
+      dataType: "jsonp",
+      data: "rpp=" + ntweets + "&show_user=true&" + query,
+      success: function(json) {
+        if (!Drupal.liveTweets.last) {
+          $('#block-live-tweets-live-tweets .content').empty();
+          $('#block-live-tweets-live-tweets').show();
+        }
 
-/**
- * Converts to UTC date then prettyDate it.
- * 
- * Z = UTC time (To express the time of day in UTC)
- * T = local time (time of day in basic format)
- * 
- * @param holds Twitter date format of Sun, 24 Jul 2011 15:43:36 +0000
- */
-liveTweets.parseDate = function(created_at) {
-	//twitter_regex_date = /(\w+[,])\s(\d{2})\s(\w+)\s(\d{4})\s(\d{2}[:]\d{2}[:]\d{2})\s([+]\d{4})/;
-	var months = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'];
-	var pattern = /\s/;
-	created_at = created_at.split(pattern);
-	for (i = 0, len = created_at.length; i < len; i++){
-		day_of_week = created_at[0];
-		day = created_at[1];
-		month_pos = created_at[2];
-		month = 0 + months.indexOf(month_pos) + 1; // add 1 because array starts from zero
-		year = created_at[3];
-		time = created_at[4];
-	}
-	created_at = year+'-'+month+'-'+day+'T'+time+'Z'; //2011-07-24T19:18:357Z
-	created_at = prettyDate(created_at);
-	
-	if(created_at != undefined)
-	return created_at;
-}
+        // Append tweets
+        for (var i = 0; i < json.results.length; i += 1) {
+          if (Drupal.liveTweets.last) {
+            var tweets = $('#block-live-tweets-live-tweets .content .tweet');
+            if (tweets.length + 1 > ntweets) {
+              $(tweets.eq(tweets.length - 1)).remove();
+            }
+            $('#block-live-tweets-live-tweets .content').prepend(
+            '<div class="tweet clearfix">'
+            + '<div class="fusion-float-imagefield-left imagecache">' + Drupal.liveTweets.parseAvatar(json.results[i].profile_image_url) + '</div>'
+            + '<div id="tweet-text">' + Drupal.liveTweets.parse(json.results[i].text) + '</div>'
+            + '<div id="tweet-created">' + Drupal.liveTweets.parseDate(json.results[i].created_at) + '</div>'
+            + '</div>');
+          }
+          else {
+            $('#block-live-tweets-live-tweets .content').append('<div class="tweet">' + Drupal.liveTweets.parseAvatar(json.results[i].profile_image_url) + Drupal.liveTweets.parse(json.results[i].text) + '</div>');
+          }
+        }
+        // Store last tweet id
+        if (json.results.length > 0) {
+          Drupal.liveTweets.last = json.results[0].id_str;
+        }
+      }
+    });
+  };
 
-Drupal.behaviors.liveTweets = function(){ 
-	if ($('#block-live_tweets-0').length) {
-	liveTweets.update();
-	setInterval( 'liveTweets.update()', Drupal.settings.live_tweets.refresh );
-	}
-//alert(liveTweets.parseDate("Sun, 24 Jul 2011 15:43:36 +0000"));
-};
+  // Parse tweet feeds to create links
+  Drupal.liveTweets.parse = function (text) {
+    // Convert urls to links
+    text = text.replace(/((http|https):\/\/[^ ]*)/g, '<a href="$1" target="_blank">$1</a> ');
+    // @User links
+    text = text.replace(/(^|\s)@(\w+)/g, '$1<a href="http://twitter.com/$2" target="_blank">@$2</a>');
+    // #Search links
+    text = text.replace(/(^|\s)#(\w+)/g, '$1<a href="http://search.twitter.com/search?q=%23$1" target="_blank">#$2</a>');
+    return text
+  };
 
+  /**
+   * Parse tweet feeds to display avatar
+   *
+   */
+  Drupal.liveTweets.parseAvatar = function(profile_image_url) {
+    profile_image_url = '<img src="' + profile_image_url + '"/>';
+    return profile_image_url;
+  }
 
+  /**
+   * Converts to UTC date then prettyDate it.
+   *
+   * Z = UTC time (To express the time of day in UTC)
+   * T = local time (time of day in basic format)
+   *
+   * @param holds Twitter date format of Sun, 24 Jul 2011 15:43:36 +0000
+   */
+  Drupal.liveTweets.parseDate = function(created_at) {
+    //twitter_regex_date = /(\w+[,])\s(\d{2})\s(\w+)\s(\d{4})\s(\d{2}[:]\d{2}[:]\d{2})\s([+]\d{4})/;
+    var months = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'];
+    var pattern = /\s/;
+    created_at = created_at.split(pattern);
+    for (i = 0, len = created_at.length; i < len; i++){
+      day_of_week = created_at[0];
+      day = created_at[1];
+      month_pos = created_at[2];
+      month = 0 + months.indexOf(month_pos) + 1; // add 1 because array starts from zero
+      year = created_at[3];
+      time = created_at[4];
+    }
+    created_at = year+'-'+month+'-'+day+'T'+time+'Z'; //2011-07-24T19:18:357Z
+    created_at = prettyDate(created_at);
+
+    if (created_at != undefined) {
+      return created_at;
+    }
+  }
+
+})(jQuery);
diff --git a/live_tweets.info b/live_tweets.info
index e16fffd..c7f9e20 100755
--- a/live_tweets.info
+++ b/live_tweets.info
@@ -1,5 +1,4 @@
 name = "Live tweets"
 description = "Provides a block with live tweets udated in real time"
-core = 6.x
-php = 5.1
-version = "6.x-0.1"
\ No newline at end of file
+core = 7.x
+version = "7.x-0.1"
diff --git a/live_tweets.module b/live_tweets.module
index 99fb15b..05522d5 100755
--- a/live_tweets.module
+++ b/live_tweets.module
@@ -1,60 +1,99 @@
 <?php
-function live_tweets_block($op='list', $delta=0, $edit=array()) {
-
-   switch ($op) {
-     case 'list':
-       $blocks[0]['info'] = t('Live tweets');
-       return $blocks;
-     case 'view':
-       $blocks['subject'] = t('Live Tweets');
-       $blocks['content'] = t('Loading tweets...');       
-       return $blocks;
-     case 'configure':
+/**
+ * Implements hook_block_info().
+ */
+function live_tweets_block_info() {
+  $blocks = array();
+
+  $blocks['live_tweets'] = array(
+    'info' => t('Live Tweets'),
+    'cache' => DRUPAL_NO_CACHE,
+  );
+
+  return $blocks;
+}
+
+/**
+ * Implements hook_block_view().
+ */
+function live_tweets_block_view($delta = '') {
+  $block = array();
+
+  switch ($delta) {
+    case 'live_tweets':
+      $block['subject'] = t('Live Tweets');
+      $block['content'] = array(
+        '#title' => t('Live Tweets'),
+        '#markup' => t('Loading tweets...'),
+      );
+      break;
+  }
+
+  return $block;
+}
+
+/**
+ * Implements hook_block_configure().
+ */
+function live_tweets_block_configure($delta = '') {
+  $form = array();
+
+  switch ($delta) {
+    case 'live_tweets':
       $form['live_tweets'] = array(
-      '#type' => 'fieldset',
-      '#title' => t('Live tweets'),
-      '#tree' => TRUE,
+        '#type' => 'fieldset',
+        '#title' => t('Live tweets'),
+        '#tree' => TRUE,
       );
       $form['live_tweets']['keywords'] = array(
-      '#type' => 'textfield',
-      '#title' => t('Search query'),
-      '#default_value' => variable_get('live_tweets_block_keywords', 'Drupal'),
-      '#description' => t('List of keywords and operators separated by spaces. ex: keyword OR from:user See !url for more info.', array ('!url' => l('http://search.twitter.com/api/', null)) ),
+        '#type' => 'textfield',
+        '#title' => t('Search query'),
+        '#default_value' => variable_get('live_tweets_block_keywords', 'Drupal'),
+        '#description' => t('List of keywords and operators separated by spaces. ex: keyword OR from:user See !url for more info.', array ('!url' => l('http://search.twitter.com/api/', null)) ),
       );
       $form['live_tweets']['ntweets'] = array(
-      '#type' => 'select',
-      '#title' => t('Number of tweets'),
-      '#description' => t('Number of tweets that will be displayed'),
-      '#default_value' => variable_get('live_tweets_block_ntweets', 3),
-      '#options' => array('3' => 3, '4' => 4, '5' => 5,  '6' => 6, '10' => 12),
+        '#type' => 'select',
+        '#title' => t('Number of tweets'),
+        '#description' => t('Number of tweets that will be displayed'),
+        '#default_value' => variable_get('live_tweets_block_ntweets', 3),
+        '#options' => drupal_map_assoc(array(3, 4, 5, 6, 10)),
       );
       $form['live_tweets']['refresh'] = array(
-      '#type' => 'select',
-      '#title' => t('Refresh time'),
-      '#description' => t('Time interval to search for new tweets'), 
-      '#default_value' => variable_get('live_tweets_block_refresh', 30),
-      '#options' => array('10' => '10s', '20' => '20s', '30' => '30s', '60' => '1min'),
+        '#type' => 'select',
+        '#title' => t('Refresh time'),
+        '#description' => t('Time interval to search for new tweets'),
+        '#default_value' => variable_get('live_tweets_block_refresh', 30),
+        '#options' => array('10' => '10s', '20' => '20s', '30' => '30s', '60' => '1min'),
       );
-      return $form;
-      
-     case 'save':
-       variable_set('live_tweets_block_keywords', check_plain($edit['live_tweets']['keywords']));
-       variable_set('live_tweets_block_ntweets', check_plain($edit['live_tweets']['ntweets']));
-       variable_set('live_tweets_block_refresh', check_plain($edit['live_tweets']['refresh']));
-      return null; 
-   }
+      break;
+  }
 
+  return $form;
 }
-/*
- *  Implementation of hook_init()
+
+/**
+ * Implements hook_block_save().
+ */
+function live_tweets_block_save($delta = '', $edit = array()) {
+  switch ($delta) {
+    case 'live_tweets':
+      variable_set('live_tweets_block_keywords', check_plain($edit['live_tweets']['keywords']));
+      variable_set('live_tweets_block_ntweets', check_plain($edit['live_tweets']['ntweets']));
+      variable_set('live_tweets_block_refresh', check_plain($edit['live_tweets']['refresh']));
+    break;
+  }
+}
+
+/**
+ * Implements hook_init()
  */
 function live_tweets_init() {
-       $path = drupal_get_path('module', 'live_tweets');       
-       drupal_add_js($path . '/js/live_tweets.js');
-			 drupal_add_js($path .'/js/pretty.js');
-       drupal_add_js(array('live_tweets' => array(
-              'keywords' => urlencode(variable_get('live_tweets_block_keywords', 'Drupal')),
-              'ntweets' => variable_get('live_tweets_block_ntweets', '3'),
-              'refresh' => variable_get('live_tweets_block_refresh', 30) * 1000,
-       )), 'setting');
-}
\ No newline at end of file
+  $path = drupal_get_path('module', 'live_tweets');
+  drupal_add_js($path . '/js/live_tweets.js');
+  drupal_add_js($path .'/js/pretty.js');
+  drupal_add_js(array('live_tweets' => array(
+    'keywords' => urlencode(variable_get('live_tweets_block_keywords', 'Drupal')),
+    'ntweets' => variable_get('live_tweets_block_ntweets', '3'),
+    'refresh' => variable_get('live_tweets_block_refresh', 30) * 1000,
+  )), 'setting');
+}
