diff --git a/format_number.info b/format_number.info
index 86dbd55..df7c7dc 100644
--- a/format_number.info
+++ b/format_number.info
@@ -1,3 +1,5 @@
 name = Format Number API
 description = This module provides a method to configure number formats (site default and user defined) with configurable decimal point and thousand separators. It also exposes several functions that can be used by other contributed or custom modules to display numbers accordingly.
-core = 6.x
+core = 7.x
+
+files[] = format_number.module
diff --git a/format_number.install b/format_number.install
index a91734a..306391b 100644
--- a/format_number.install
+++ b/format_number.install
@@ -1,4 +1,5 @@
 <?php
+// $Id$
 
 /**
  * @file
diff --git a/format_number.js b/format_number.js
index 93edb0c..c2b8bd2 100644
--- a/format_number.js
+++ b/format_number.js
@@ -1,17 +1,9 @@
-
 (function ($) {
 
 /**
  * Create our own namespace in the global Drupal object.
  */
-Drupal.numericElement = Drupal.numericElement || {};
-
-/**
- * Attach Drupal behavior to numeric input elements.
- */
-Drupal.behaviors.numericElement = function(context) {
-  Drupal.numericElement.attach(context);
-};
+  Drupal.numericElement = Drupal.numericElement || {};
 
 /**
  * Format a number with (site default or user defined) thousands separator
@@ -28,64 +20,66 @@ Drupal.behaviors.numericElement = function(context) {
  * @return string
  *   The formatted number.
  */
-Drupal.formatNumber = function(number, decimals, truncate) {
-  if (typeof(number) != 'number') {
-    number = 0;
-  }
-  if (typeof(decimals) != 'number') {
-    decimals = 0;
-  }
-  if (typeof(truncate) == 'undefined') {
-    truncate = true;
-  }
-
-  // Round the number to the specified number of decimals if requested to.
-  // Otherwise, the decimal part will be trucated.
-  if (decimals > 0 && !truncate) {
-    number = Math.round(number * Math.pow(10, decimals)) / Math.pow(10, decimals);
-  }
-
-  // Obtain the sign and separate integer/decimal parts.
-  var minus_sign = (number < 0 ? '-' : '');
-  var number_parts = (Math.abs(number) + '').split('.');
-
-  // Get the integer part of the number.
-  var integer_part = (number_parts[0].length > 0 ? number_parts[0] : '0');
-
-  // Insert thousands separator when necessary.
-  if (Drupal.settings.format_number.thousands_sep.length > 0) {
-    // Reverse the interger part into an array.
-    var digits = integer_part.split('').reverse();
-    integer_part = '';
-    // Add thousands separator every 3 digits.
-    for (var i = 0; i < digits.length; i++) {
-      integer_part += ((i % 3) == 0 && i > 0 ? Drupal.settings.format_number.thousands_sep : '') + digits[i];
-    }
-    // Reverse back the integer part.
-    integer_part = integer_part.split('').reverse().join('');
-  }
-  number = minus_sign + integer_part;
-
-  // Build the decimal part of the number.
-  if (decimals > 0) {
-    var decimal_part = (number_parts.length <= 1 ? '0' : number_parts[1]);
-    if (decimal_part.length > decimals) {
-      decimal_part = decimal_part.substr(0, decimals);
-    }
-    else if (decimal_part.length < decimals) {
-      while (decimal_part.length < decimals) { decimal_part += '0'; }
-    }
-    number += Drupal.settings.format_number.decimal_point + decimal_part;
-  }
-
-  // When no decimals have been specified, we allow any. This is used for
-  // min/max fields in CCK field settings.
-  else if (decimals < 0 && number_parts.length > 1) {
-    number += Drupal.settings.format_number.decimal_point + number_parts[1];
-  }
-
-  return number;
-};
+  Drupal.formatNumber = function(number, decimals, truncate) {
+    if (typeof(number) != 'number') {
+      number = 0;
+    }
+    if (typeof(decimals) != 'number') {
+      decimals = 0;
+    }
+    if (typeof(truncate) == 'undefined') {
+      truncate = true;
+    }
+
+    // Round the number to the specified number of decimals if requested to.
+    // Otherwise, the decimal part will be trucated.
+    if (decimals > 0 && !truncate) {
+      number = Math.round(number * Math.pow(10, decimals)) / Math.pow(10, decimals);
+    }
+
+    // Obtain the sign and separate integer/decimal parts.
+    var minus_sign = (number < 0 ? '-' : '');
+    var number_parts = (Math.abs(number) + '').split('.');
+
+    // Get the integer part of the number.
+    var integer_part = (number_parts[0].length > 0 ? number_parts[0] : '0');
+
+    // Insert thousands separator when necessary.
+    if (Drupal.settings.format_number.thousands_sep.length > 0) {
+      // Reverse the interger part into an array.
+      var digits = integer_part.split('').reverse();
+      integer_part = '';
+      // Add thousands separator every 3 digits.
+      for (var i = 0; i < digits.length; i++) {
+        integer_part += ((i % 3) == 0 && i > 0 ? Drupal.settings.format_number.thousands_sep : '') + digits[i];
+      }
+      // Reverse back the integer part.
+      integer_part = integer_part.split('').reverse().join('');
+    }
+    number = minus_sign + integer_part;
+
+    // Build the decimal part of the number.
+    if (decimals > 0) {
+      var decimal_part = (number_parts.length <= 1 ? '0' : number_parts[1]);
+      if (decimal_part.length > decimals) {
+        decimal_part = decimal_part.substr(0, decimals);
+      }
+      else if (decimal_part.length < decimals) {
+        while (decimal_part.length < decimals) {
+          decimal_part += '0';
+        }
+      }
+      number += Drupal.settings.format_number.decimal_point + decimal_part;
+    }
+
+    // When no decimals have been specified, we allow any. This is used for
+    // min/max fields in CCK field settings.
+    else if (decimals < 0 && number_parts.length > 1) {
+      number += Drupal.settings.format_number.decimal_point + number_parts[1];
+    }
+
+    return number;
+  };
 
 /**
  * Parse a number with (site default or user defined) thousands separator
@@ -101,45 +95,45 @@ Drupal.formatNumber = function(number, decimals, truncate) {
  * @return number
  *   A valid number.
  */
-Drupal.parseNumber = function(number, required) {
-  if (typeof(number) != 'string') {
-    return (typeof(number) == 'number' ? number : 0);
-  }
-  if (required == undefined) {
-    required = true;
-  }
-
-  // Get rid of leading/trailing whitespaces.
-  if ((number = number.replace(/^\s+|\s+$/g, '')) == '') {
-    return (required ? 0 : '');
-  }
-
-  // Extract sign and temporarily remove it from input.
-  var is_negative = (number[0] == '-');
-  if (is_negative) {
-    number = number.substr(1);
-  }
-
-  // Remove thousands separators, if any.
-  if (Drupal.settings.format_number.thousands_sep.length > 0) {
-    var thsep = Drupal.settings.format_number.thousands_sep;
-    if (thsep == '\u00A0') {
-      thsep += ' ';
-    }
-    number = number.replace(new RegExp('[' + thsep + ']', 'g'), '');
-  }
-
-  // Translate decimal point, if necessary.
-  if (Drupal.settings.format_number.decimal_point != '.') {
-    number = number.replace(new RegExp('[' + Drupal.settings.format_number.decimal_point + ']', 'g'), '.');
-  }
-
-  // Truncate from first non-numeric character (at this point only 0-9 and
-  // just one dot are allowed).
-  // This should also restore back the sign (if necessary) and convert the
-  // string into a pure javascript number (integer or float).
-  return number.replace(/^([0-9]*\.?[0-9]+)?.*$/, '$1') * (is_negative ? -1 : 1);
-};
+  Drupal.parseNumber = function(number, required) {
+    if (typeof(number) != 'string') {
+      return (typeof(number) == 'number' ? number : 0);
+    }
+    if (required == undefined) {
+      required = true;
+    }
+
+    // Get rid of leading/trailing whitespaces.
+    if ((number = number.replace(/^\s+|\s+$/g, '')) == '') {
+      return (required ? 0 : '');
+    }
+
+    // Extract sign and temporarily remove it from input.
+    var is_negative = (number[0] == '-');
+    if (is_negative) {
+      number = number.substr(1);
+    }
+
+    // Remove thousands separators, if any.
+    if (Drupal.settings.format_number.thousands_sep.length > 0) {
+      var thsep = Drupal.settings.format_number.thousands_sep;
+      if (thsep == '\u00A0') {
+        thsep += ' ';
+      }
+      number = number.replace(new RegExp('[' + thsep + ']', 'g'), '');
+    }
+
+    // Translate decimal point, if necessary.
+    if (Drupal.settings.format_number.decimal_point != '.') {
+      number = number.replace(new RegExp('[' + Drupal.settings.format_number.decimal_point + ']', 'g'), '.');
+    }
+
+    // Truncate from first non-numeric character (at this point only 0-9 and
+    // just one dot are allowed).
+    // This should also restore back the sign (if necessary) and convert the
+    // string into a pure javascript number (integer or float).
+    return number.replace(/^([0-9]*\.?[0-9]+)?.*$/, '$1') * (is_negative ? -1 : 1);
+  };
 
 /**
  * Attach Drupal behavior to numeric input elements.
@@ -151,38 +145,40 @@ Drupal.parseNumber = function(number, required) {
  * - on form submit   : Thousands separator are removed to prevent from triggering
  *                      maxlength error during Forms API validation.
  */
-Drupal.numericElement.attach = function(context) {
-  $('input.form-numeric:not(.form-numeric-processed)', context).addClass('form-numeric-processed').each(function() {
-    var $element = $(this);
-
-    // Number of decimal places for this element.
-    var decimals = $element.attr('decimals');
-    decimals = (decimals == undefined ? -1 : Math.max(-1, parseInt(decimals)));
-
-    // The element is properly formatted on page load.
-    Drupal.numericElement.formatElement($element, decimals);
-
-    // Bind element events.
-    $element.bind('focus', function() {
-      Drupal.numericElement.clearThousandsSep($element);
-    }).bind('blur', function() {
-      Drupal.numericElement.formatElement($element, decimals);
-    });
-
-    // Bind submit event callback to the form.
-    $element.parents('form:not(.form-numeric-processed)').addClass('form-numeric-processed').each(function() {
-      // Clear thousands separators before submitting. This is not strictly
-      // necessary because input is always validated on the server, but it
-      // prevents from getting "field cannot be longer than max" errors issued
-      // by Forms API.
-      $(this).bind('submit', function() {
-        $('input.form-numeric', this).each(function() {
-          Drupal.numericElement.clearThousandsSep($(this));
+  Drupal.behaviors.numericElement = {
+    attach: function(context) {
+      $('input.form-numeric:not(.form-numeric-processed)', context).addClass('form-numeric-processed').each(function() {
+        var $element = $(this);
+
+        // Number of decimal places for this element.
+        var decimals = $element.attr('decimals');
+        decimals = (decimals == undefined ? -1 : Math.max(-1, parseInt(decimals)));
+
+        // The element is properly formatted on page load.
+        Drupal.numericElement.formatElement($element, decimals);
+
+        // Bind element events.
+        $element.bind('focus', function() {
+          Drupal.numericElement.clearThousandsSep($element);
+        }).bind('blur', function() {
+          Drupal.numericElement.formatElement($element, decimals);
+        });
+
+        // Bind submit event callback to the form.
+        $element.parents('form:not(.form-numeric-processed)').addClass('form-numeric-processed').each(function() {
+          // Clear thousands separators before submitting. This is not strictly
+          // necessary because input is always validated on the server, but it
+          // prevents from getting "field cannot be longer than max" errors issued
+          // by Forms API.
+          $(this).bind('submit', function() {
+            $('input.form-numeric', this).each(function() {
+              Drupal.numericElement.clearThousandsSep($(this));
+            });
+          });
         });
       });
-    });
-  });
-};
+    }
+  };
 
 /**
  * Clear thousands separators from the given input element.
@@ -190,17 +186,17 @@ Drupal.numericElement.attach = function(context) {
  * @param $element
  *   The input element.
  */
-Drupal.numericElement.clearThousandsSep = function($element) {
-  var number = $element.val();
-  if (number.length > 0 && Drupal.settings.format_number.thousands_sep.length > 0) {
-    var thsep = Drupal.settings.format_number.thousands_sep;
-    if (thsep == '\u00A0') {
-      thsep += ' ';
-    }
-    number = number.replace(new RegExp('['+ thsep +']', 'g'), '');
-    $element.val(number);
-  }
-};
+  Drupal.numericElement.clearThousandsSep = function($element) {
+    var number = $element.val();
+    if (number.length > 0 && Drupal.settings.format_number.thousands_sep.length > 0) {
+      var thsep = Drupal.settings.format_number.thousands_sep;
+      if (thsep == '\u00A0') {
+        thsep += ' ';
+      }
+      number = number.replace(new RegExp('['+ thsep +']', 'g'), '');
+      $element.val(number);
+    }
+  };
 
 /**
  * Format the number in the given element with site/user defined options.
@@ -210,15 +206,15 @@ Drupal.numericElement.clearThousandsSep = function($element) {
  * @param decimals
  *   Number of decimal digits.
  */
-Drupal.numericElement.formatElement = function($element, decimals) {
-  var number = $element.val();
-  if (number.length > 0) {
-    number = Drupal.parseNumber(number, false);
-    if (typeof(number) == 'number') {
-      number = Drupal.formatNumber(number, decimals);
-    }
-    $element.val(number);
-  }
-};
+  Drupal.numericElement.formatElement = function($element, decimals) {
+    var number = $element.val();
+    if (number.length > 0) {
+      number = Drupal.parseNumber(number, false);
+      if (typeof(number) == 'number') {
+        number = Drupal.formatNumber(number, decimals);
+      }
+      $element.val(number);
+    }
+  };
 
 })(jQuery);
diff --git a/format_number.module b/format_number.module
index 9a3391b..be4a8eb 100644
--- a/format_number.module
+++ b/format_number.module
@@ -1,5 +1,7 @@
 <?php
 
+// $Id$
+
 /**
  * @file
  * This module provides a method to configure number formats (site default and
@@ -8,34 +10,39 @@
  * custom modules to display numbers accordingly.
  */
 
-/**
- * Maximum allowed decimal digits.
- */
+//Maximum allowed decimal digits.
 define('FORMAT_NUMBER_MAX_PRECISION', 8);
 
 /**
- * Implementation of hook_help().
+ * Implements hook_help().
  */
 function format_number_help($path, $arg) {
   switch ($path) {
     case 'admin/help#format_number':
-      return '<p>'. t('The <em>Format Number API</em> module provides a method to configure number formats (site default and user defined) with configurable decimal point and thousand separators. It also exposes several functions that can be used by other contributed or custom modules to display numbers accordingly.') .'</p>';
+      return '<p>' . t('The <em>Format Number API</em> module provides a method to configure number formats (site
+        default and user defined) with configurable decimal point and thousand separators. It also exposes several
+        functions that can be used by other contributed or custom modules to display numbers accordingly.') . '</p>';
   }
 }
 
 /**
- * Implementation of hook_perm().
+ * Implements hook_permission().
  */
-function format_number_perm() {
-  return array('configure default number format');
+function format_number_permission() {
+  return array(
+    'configure default number format' => array(
+      'title' => t('Configure default number format'),
+    //'description' => t('Modify format number global settings.'),
+    ),
+  );
 }
 
 /**
- * Implementation of hook_menu().
+ * Implements hook_menu().
  */
 function format_number_menu() {
   $items = array();
-  $items['admin/settings/format_number'] = array(
+  $items['admin/config/regional/format_number'] = array(
     'title' => 'Number format',
     'description' => 'Configure site wide number format settings.',
     'page callback' => 'drupal_get_form',
@@ -47,34 +54,44 @@ function format_number_menu() {
 }
 
 /**
- * Implementation of hook_theme().
+ * Implements hook_theme().
  */
 function format_number_theme() {
   return array(
-    'numericfield' => array('arguments' => array('element' => NULL)),
+    'numericfield' => array(
+      'render element' => 'element',
+    ),
   );
 }
 
 /**
- * Implementation of hook_user().
- *
+ * Implements hook_form_user_profile_form_alter().
+ * 
  * Allows users to individually set their number format.
  */
-function format_number_user($type, &$edit, &$user, $category = NULL) {
-  if ($type == 'form' && $category == 'account' && variable_get('format_number_user_configurable', 0)) {
+function format_number_form_user_profile_form_alter(&$form, &$form_state) {
+  if ($form['#user_category'] == 'account' && variable_get('format_number_user_configurable', 0)) {
     module_load_include('inc', 'format_number', 'format_number.settings');
-    return format_number_settings_user($edit);
+    $form += format_number_settings_user($form_state['user']->data);
+    $form['#validate'][] = 'format_number_settings_user_validate';
   }
-  elseif ($type == 'validate' && $category == 'account' && variable_get('format_number_user_configurable', 0)) {
-    module_load_include('inc', 'format_number', 'format_number.settings');
-    format_number_settings_user_validate($edit);
-    return;
+}
+
+/**
+ * Implements hook_user_presave().
+ */
+function format_number_user_presave(&$edit, $account, $category) {
+  if (isset($edit['decimal_point'])) {
+    $edit['data']['decimal_point'] = $edit['decimal_point'];
+  }
+
+  if (isset($edit['thousands_sep'])) {
+    $edit['data']['thousands_sep'] = $edit['thousands_sep'];
   }
 }
 
 /**
  * Get decimal point options.
- *
  * @see http://www.unicode.org/cldr/data/charts/by_type/number.symbol.html
  */
 function format_number_get_decimal_point_options() {
@@ -87,7 +104,7 @@ function format_number_get_decimal_point_options() {
 
 /**
  * Get thousands separator options.
- *
+ * 
  * @see http://www.unicode.org/cldr/data/charts/by_type/number.symbol.html
  */
 function format_number_get_thousands_separator_options() {
@@ -105,7 +122,7 @@ function format_number_get_thousands_separator_options() {
 
 /**
  * Get the site/user defined thousands separator and decimal point characters.
- *
+ * 
  * @param string $name
  *   The name of the option to retrieve (optional). Available options:
  *   - 'thousands_sep'  A one character string (it could be empty).
@@ -124,11 +141,11 @@ function format_number_get_options($name = NULL) {
       'decimal_point' => variable_get('format_number_decimal_point', '.'),
     );
     if (variable_get('format_number_user_configurable', 0) && $user->uid) {
-      if (drupal_strlen($user->thousands_sep)) {
-        $format_options['thousands_sep'] = $user->thousands_sep;
+      if (isset($user->data['thousands_sep']) && drupal_strlen($user->data['thousands_sep'])) {
+        $format_options['thousands_sep'] = $user->data['thousands_sep'];
       }
-      if (drupal_strlen($user->decimal_point)) {
-        $format_options['decimal_point'] = $user->decimal_point;
+      if (isset($user->data['decimal_point']) && drupal_strlen($user->data['decimal_point'])) {
+        $format_options['decimal_point'] = $user->data['decimal_point'];
       }
     }
   }
@@ -146,16 +163,15 @@ function format_number_add_js() {
   if (!isset($ready)) {
     $ready = TRUE;
     $module_path = drupal_get_path('module', 'format_number');
-    drupal_add_css($module_path .'/format_number.css');
-    drupal_add_js($module_path .'/format_number.js');
+    drupal_add_css($module_path . '/format_number.css');
+    drupal_add_js($module_path . '/format_number.js');
     drupal_add_js(array('format_number' => format_number_get_options()), 'setting');
   }
 }
 
 /**
- * Format a number with (site default or user defined) thousands separator and
- * decimal point.
- *
+ * Format a number with (site default or user defined) thousands separator and decimal point.
+ * 
  * @param float $number
  *   The number being formatted.
  * @param int $decimals
@@ -171,7 +187,7 @@ function format_number($number, $decimals = 0) {
 
   // Perform an initial conversion using PHP's number_format() that
   // seems to work better than sprintf().
-  $number = number_format((float)$number, FORMAT_NUMBER_MAX_PRECISION, '.', '');
+  $number = number_format((float) $number, FORMAT_NUMBER_MAX_PRECISION, '.', '');
 
   if ($decimals < 0) {
     // Count decimal places (ignoring trailing zeros to the right of the decimal point).
@@ -189,7 +205,7 @@ function format_number($number, $decimals = 0) {
 
 /**
  * Formats numbers to a specified number of significant figures.
- *
+ * 
  * @param number $number
  *   The number to format.
  * @param integer $significant_figures
@@ -256,7 +272,7 @@ function parse_formatted_number($formatted_number, $required = TRUE) {
     $formatted_number = drupal_substr($formatted_number, 1);
   }
   else {
-    $last_char = $formatted_number[drupal_strlen($formatted_number)-1];
+    $last_char = $formatted_number[drupal_strlen($formatted_number) - 1];
     if ($last_char == '-' || $last_char == '+') {
       $is_negative = ($last_char == '-' ? TRUE : FALSE);
       $formatted_number = drupal_substr($formatted_number, 0, -1);
@@ -266,7 +282,7 @@ function parse_formatted_number($formatted_number, $required = TRUE) {
   // Extract non-numeric symbols.
   preg_match_all('#[^0-9]#u', $formatted_number, $matches);
   $non_numeric_symbols = array_count_values($matches[0]);
-  $non_numeric_symbols_count = count($non_numeric_symbols); 
+  $non_numeric_symbols_count = count($non_numeric_symbols);
   if ($non_numeric_symbols_count > 2) {
     // More than two different non-numeric symbols.
     return FALSE;
@@ -358,17 +374,18 @@ function parse_formatted_number($formatted_number, $required = TRUE) {
 }
 
 /**
- * Implementation of hook_elements().
+ * Implements hook_element_info().
  */
-function format_number_elements() {
-  return array(
-    'numericfield' => array(
-      '#input' => TRUE,
-      '#precision' => 12,
-      '#decimals' => 0,
-      '#process' => array('format_number_numericfield_process'),
-    ),
+function format_number_element_info() {
+  $types['numericfield'] = array(
+    '#input' => TRUE,
+    '#precision' => 12,
+    '#decimals' => 0,
+    '#process' => array('format_number_process_numericfield'),
+    '#element_validate' => array('format_number_validate_numericfield'),
+    '#theme' => 'numericfield',
   );
+  return $types;
 }
 
 /**
@@ -387,7 +404,7 @@ function format_number_elements() {
  *   The minimum or maximum possible value.
  */
 function format_number_compute_boundary($direction, $precision = 0, $decimals = 0) {
-  return (float)(($direction == 'lower' ? '-' : '') . str_repeat('9', $precision - $decimals) .'.'. str_repeat('9', $decimals));
+  return (float) (($direction == 'lower' ? '-' : '') . str_repeat('9', $precision - $decimals) . '.' . str_repeat('9', $decimals));
 }
 
 /**
@@ -404,9 +421,9 @@ function format_number_compute_boundary($direction, $precision = 0, $decimals =
  *
  * @ingroup forms
  */
-function format_number_numericfield_process($element, $edit, $form_state, $form) {
-  $element_precision = (isset($element['#precision']) && (int)$element['#precision'] > 0 ? (int)$element['#precision'] : 12);
-  $element_decimals = (isset($element['#decimals']) && (int)$element['#decimals'] >= 0 ? (int)$element['#decimals'] : 0);
+function format_number_process_numericfield($element, &$form_state) {
+  $element_precision = (isset($element['#precision']) && (int) $element['#precision'] > 0 ? (int) $element['#precision'] : 12);
+  $element_decimals = (isset($element['#decimals']) && (int) $element['#decimals'] >= 0 ? (int) $element['#decimals'] : 0);
   $element_minimum = (isset($element['#minimum']) ? parse_formatted_number($element['#minimum']) : NULL);
   if (!is_numeric($element_minimum)) {
     $element_minimum = format_number_compute_boundary('lower', $element_precision, $element_decimals);
@@ -452,15 +469,7 @@ function format_number_numericfield_process($element, $edit, $form_state, $form)
   else {
     $element['#attributes'] = array('decimals' => $element_decimals);
   }
-
-  // Attach a validation callback to the form element.
-  if (isset($element['#element_validate']) && is_array($element['#element_validate'])) {
-    array_shift($element['#element_validate'], 'format_number_numericfield_validate');
-  }
-  else {
-    $element['#element_validate'] = array('format_number_numericfield_validate');
-  }
-
+  
   return $element;
 }
 
@@ -502,7 +511,7 @@ function form_type_numericfield_value($element, $edit = FALSE) {
  *
  * @ingroup forms
  */
-function format_number_numericfield_validate($element, &$form_state) {
+function format_number_validate_numericfield(&$element, &$form_state) {
   $value = $element['#value'];
 
   if ($element['#required'] || $value != '') {
@@ -515,8 +524,8 @@ function format_number_numericfield_validate($element, &$form_state) {
     }
 
     // Validate number boundaries.
-    $element_precision = (isset($element['#precision']) && (int)$element['#precision'] > 0 ? (int)$element['#precision'] : 12);
-    $element_decimals = (isset($element['#decimals']) && (int)$element['#decimals'] >= 0 ? (int)$element['#decimals'] : 0);
+    $element_precision = (isset($element['#precision']) && (int) $element['#precision'] > 0 ? (int) $element['#precision'] : 12);
+    $element_decimals = (isset($element['#decimals']) && (int) $element['#decimals'] >= 0 ? (int) $element['#decimals'] : 0);
     $element_minimum = (isset($element['#minimum']) ? parse_formatted_number($element['#minimum']) : NULL);
     if (!is_numeric($element_minimum)) {
       $element_minimum = format_number_compute_boundary('lower', $element_precision, $element_decimals);
@@ -552,23 +561,16 @@ function format_number_numericfield_validate($element, &$form_state) {
  *
  * @ingroup themeable
  */
-function theme_numericfield($element) {
-  format_number_add_js();
+function theme_numericfield($variables) {
+  $element = $variables['element'];
 
-  $size = empty($element['#size']) ? '' : ' size="'. $element['#size'] .'"';
-  $maxlength = empty($element['#maxlength']) ? '' : ' maxlength="'. $element['#maxlength'] .'"';
-  $output = '';
-  _form_set_class($element, array('form-numeric'));
-
-  if (isset($element['#field_prefix'])) {
-    $output .= '<span class="field-prefix">'. $element['#field_prefix'] .'</span> ';
-  }
+  format_number_add_js();
 
-  $output .= '<input type="text"'. $maxlength .' name="'. $element['#name'] .'" id="'. $element['#id'] .'"'. $size .' value="'. check_plain($element['#value']) .'"'. drupal_attributes($element['#attributes']) .' />';
+  $element['#attributes']['type'] = 'text';
+  element_set_attributes($element, array('id', 'name', 'value', 'size', 'maxlength'));
+  _form_set_class($element, array('form-text', 'form-numeric'));
 
-  if (isset($element['#field_suffix'])) {
-    $output .= ' <span class="field-suffix">'. $element['#field_suffix'] .'</span>';
-  }
+  $variables['element']['#children'] = '<input' . drupal_attributes($element['#attributes']) . ' />';
 
-  return theme('form_element', $element, $output);
+  return theme('form_element', $variables);
 }
diff --git a/format_number.settings.inc b/format_number.settings.inc
index 244d60e..82a34d9 100644
--- a/format_number.settings.inc
+++ b/format_number.settings.inc
@@ -1,5 +1,7 @@
 <?php
 
+// $Id$
+
 /**
  * @file
  * Implement module settings and user settings forms.
@@ -31,6 +33,7 @@ function format_number_settings_site() {
     '#options' => array(t('Disabled'), t('Enabled')),
     '#description' => t('When enabled, users can set their own number formatting options.'),
   );
+
   $form['#validate'] = array('format_number_settings_site_validate');
   return system_settings_form($form);
 }
@@ -64,14 +67,14 @@ function format_number_settings_user(&$edit) {
     '#type' => 'radios',
     '#title' => t('Decimal point'),
     '#options' => format_number_get_decimal_point_options(),
-    '#default_value' => drupal_strlen($edit['decimal_point']) ? $edit['decimal_point'] : variable_get('format_number_decimal_point', '.'),
+    '#default_value' => isset($edit['decimal_point']) && drupal_strlen($edit['decimal_point']) ? $edit['decimal_point'] : variable_get('format_number_decimal_point', '.'),
     '#description' => t('Select the character that will be used as decimal point.'),
   );
   $form['format_number']['thousands_sep'] = array(
     '#type' => 'radios',
     '#title' => t('Thousands separator'),
     '#options' => format_number_get_thousands_separator_options(),
-    '#default_value' => drupal_strlen($edit['thousands_sep']) ? $edit['thousands_sep'] : variable_get('format_number_thousands_sep', ','),
+    '#default_value' => isset($edit['thousands_sep']) && drupal_strlen($edit['thousands_sep']) ? $edit['thousands_sep'] : variable_get('format_number_thousands_sep', ','),
     '#description' => t('Select the character that will be used as thousands separator.'),
   );
   return $form;
@@ -80,7 +83,8 @@ function format_number_settings_user(&$edit) {
 /**
  * Validate the user settings form.
  */
-function format_number_settings_user_validate(&$edit) {
+function format_number_settings_user_validate($form, &$form_state) {
+  $edit = $form_state['values'];
   if (isset($edit['decimal_point']) && $edit['decimal_point'] == $edit['thousands_sep']) {
     form_set_error('thousands_sep', t('Decimal point and thousands separator cannot be defined to use the same symbol.'));
   }
