diff --git a/pdir.info b/pdir.info
index b5c9ae3..10202ea 100644
--- a/pdir.info
+++ b/pdir.info
@@ -1,3 +1,8 @@
 name = Paragraph directionality
-description = "Determines the directionaliy of a paragraph"
-core = 6.x
+description = Determines the directionaliy of a paragraph.
+package = User interface
+version = VERSION
+core = 7.x
+
+files[] = pdir.install
+files[] = pdir.module
\ No newline at end of file
diff --git a/pdir.install b/pdir.install
index a1ca17b..7ae2052 100644
--- a/pdir.install
+++ b/pdir.install
@@ -1,5 +1,13 @@
 <?php
 
+/**
+ * @file
+ * Handles actions upon enabling and disabling the module.
+ */
+
+/**
+ * Implements hook_install().
+ */
 function pdir_install() {
-  drupal_set_message(t('In order to activate the paragraph directionality filter, you must !activate_it in the input formats admin screen.', array('!activate_it' => l(t('activate it'), 'admin/settings/filters'))));
+  db_query("UPDATE {system} SET weight = 999 WHERE name = 'pdir'");
 }
\ No newline at end of file
diff --git a/pdir.module b/pdir.module
index a66b8f7..3d6f5ba 100644
--- a/pdir.module
+++ b/pdir.module
@@ -2,38 +2,46 @@
 
 /**
  * @file
- * Determines the directionaliy of a paragraph
+ * Determines the directionaliy of a paragraph.
  */
 
 /**
- * Implementation of hook_filter_tips().
+ * Implements of hook_filter_info().
  */
-function pdir_filter($op, $delta = 0, $format = -1, $text = '') {
-  switch ($op) {
-    case 'no cache':
-      return FALSE;
-    case 'list':
-      return array(0 => t('Paragraph Directionality Filter'));
-    case 'description':
-      return t('Sets the directionality of a paragraph, according to it\'s first alphabetic chracter. <strong>This filter should be generally used after the Line break converter filter</strong>.');
-    case 'process':
-      return pdir_pdir($text);
-    default:
-      return $text;
-  }
+function pdir_filter_info() {
+  $filters = array(
+    'pdir' => array(
+      'title' => t('Auto set paragraphs directionality to RTL or LTR'), 
+      'description' => t('Sets the directionality of a paragraph, according to it\'s first alphabetic chracter. <strong>This filter should be generally used after the Line break converter filter</strong> in order for it to work.'), 
+      'process callback' => '_pdir_pdir',
+      'tips callback' => '_pdir_tips',
+    ),
+  );
+  return $filters;
 }
 
-function pdir_pdir($text) {
-  # find first text within a paragraph (ignore html inside paragraphs)
+/**
+ * Filter tips callback for Paragraph Directionality filter.
+ */
+function _pdir_tips($filter, $format, $long = FALSE) {
+  return t('Paragraphs directionality will be automatically set to RTL or LTR.');
+}
+
+/**
+ * Processer for text chunks tp add directionality based on first alphabetic chracter.
+ */
+function _pdir_pdir($text) {
+  // Find first text within a paragraph (ignore html inside paragraphs)
   $chunks = preg_split('@(</?[^>]*>)@i', $text, -1, PREG_SPLIT_DELIM_CAPTURE);
-  # Find block level elements, and check the next chunk
+  // Find block level elements, and check the next chunk
   $block_elements = array('<p>', '<ol>', '<ul>', '<li>', '<div>');
   $i = 0;
-  while ($i <= count($chunks)) {
+  $output = '';
+  while ($i < count($chunks)) {
     if (in_array($chunks[$i], $block_elements)) {
-      $text_chunk = pdir_text_chuck($chunks, $i+1);
+      $text_chunk = _pdir_text_chuck($chunks, $i+1);
       if ($text_chunk) {
-        $dir = pdir_determine_dir($chunks[$text_chunk]);
+        $dir = _pdir_determine_dir($chunks[$text_chunk]);
         $chunks[$i] = '<' . trim($chunks[$i], '<>')  . ' style="direction:' . $dir . '">';
         $output .= $chunks[$i];
       }
@@ -46,11 +54,11 @@ function pdir_pdir($text) {
   return $output;
 }
 
-function pdir_text_chuck($chunks, $i) {
-  # If the current chunk is a valid text, return it, otherwise, keep digging.
+function _pdir_text_chuck($chunks, $i) {
+  // If the current chunk is a valid text, return it, otherwise, keep digging.
   if (preg_match('@^<[^>]*>@u', $chunks[$i]) || empty($chunks[$i])) {
     if (isset($chunks[$i+1])) {
-      $next = pdir_text_chuck($chunks, $i+1);
+      $next = _pdir_text_chuck($chunks, $i+1);
       return $next;
     }
   }
@@ -59,7 +67,7 @@ function pdir_text_chuck($chunks, $i) {
   }
 }
 
-function pdir_determine_dir($chunk) {
+function _pdir_determine_dir($chunk) {
   // Check wehther the first alphabethic character is an RTL one (e.g., belongs to an RTL language)
   // The following line means: anything which is NOT a Letter, or digit. Pattern strings are treated as UTF-8.
   // See: http://il2.php.net/manual/en/regexp.reference.php and http://il2.php.net/manual/en/reference.pcre.pattern.modifiers.php for details.
