Modified code to drupal standards with Coder Module.