diff --git a/properties-properties-form.tpl.php b/properties-properties-form.tpl.php
index d4afcc6..32641d6 100644
--- a/properties-properties-form.tpl.php
+++ b/properties-properties-form.tpl.php
@@ -1,92 +1,19 @@
 <?php
-
-$element = $variables['element'];
-$output = '';
-
-$table_id = 'properties-table';
-
-if (user_access('add properties attributes')) {
-  $header = array(
-    t('Attribute name'),
-    t('Attribute label'),
-    t('Value'),
-    t('Category'),
-    t('Order'),
-    t('Delete'),
-  );
-}
-else {
-  $header = array(
-    t('Attribute'),
-    t('Value'),
-  );
-  if (user_access('add properties categories')) {
-    $header[] = t('Order');
-  }
-}
-$rows = array();
-if (user_access('add properties attributes') || user_access('add properties categories')) {
-  drupal_add_tabledrag($table_id, 'match', 'parent', 'property-category-select', 'property-category-select', 'category-name');
-  drupal_add_tabledrag($table_id, 'order', 'sibling', 'property-weight');
-}
-
-foreach (element_children($element['listing']) as $category_name) {
-  $category = $element['listing'][$category_name];
-  $category['_weight']['#attributes']['class'] = array('property-weight');
-  $category['name']['#attributes']['class'] = array('category-name');
-  $category['category']['#attributes']['class'] = array('property-category-select');
-
-  $cells = array();
-  $cells[] = '<strong>' . $category['#label'] . '</strong>';
-  $cells[] = '&nbsp;';
-  if (user_access('add properties attributes')) {
-    $cells[] = '&nbsp;';
-    $cells[] = '&nbsp;';
-  }
-  if (user_access('add properties categories')) {
-    $cells[] = drupal_render($category['category']) . drupal_render($category['name']) . drupal_render($category['_weight']);
-    $cells[] = drupal_render($category['delete']);
-  }
-  $rows[] = array(
-    'data' => $cells,
-    'class' => array('draggable', 'tabledrag-root'),
-  );
-
-  foreach (element_children($category['properties']) as $delta) {
-    $property = $category['properties'][$delta];
-
-    // Set special classes needed for table drag and drop.
-    $property['category']['#attributes']['class'] = array('property-category-select');
-    $property['_weight']['#attributes']['class'] = array('property-weight');
-
-    $cells = array();
-    if (user_access('add properties attributes')) {
-      $cells[] = array('data' => theme('indentation', array('size' => 1)) . drupal_render($property['attribute']), 'class' => array('properties-attribute-row-small'));
-      $cells[] = drupal_render($property['label']);
-    }
-    else {
-      $cells[] = theme('indentation', array('size' => 1)) . drupal_render($property['label']);
-    }
-
-    $cells[] = drupal_render($property['value']);
-    if (user_access('add properties attributes')) {
-      $cells[] = drupal_render($property['category']);
-      $cells[] = drupal_render($property['_weight']);
-      $cells[] = drupal_render($property['delete']);
-    }
-    elseif (user_access('add properties categories')) {
-      $cells[] = '&nbsp;';
-    }
-    $rows[] = array(
-      'data' => $cells,
-      'class' => user_access('add properties attributes') ? array('draggable', 'tabledrag-leaf') : array('properties-tabledrag-children'),
-    );
-  }
-}
-
-$output = '<div class="form-item field-widget-properties-table">';
-$output .= theme('table', array('header' => $header, 'rows' => $rows, 'attributes' => array('id' => $table_id, 'class' => array('properties-table'))));
-$output .= '<div class="clearfix inline">' . drupal_render($element['actions']) . '</div>';
-$output .= '</div>';
-
-echo $output;
+/**
+ * @file
+ * Default theme implementation of the properties form.
+ *
+ * Available variables:
+ * - $table: the rendered draggable table with properties.
+ * - $actions: the rendered buttons for the addition of categories and property fields.
+ * - $element: Provides an array with a wide range of additional internal data.
+ *
+ * @see template_preprocess_properties_properties_form()
+ */
+?>
+<div class="form-item field-widget-properties-table">
+  <?php print $table; ?>
+  <div class="clearfix inline">
+    <?php print $actions; ?>
+  </div>
+</div>
diff --git a/properties.admin.inc b/properties.admin.inc
index 03e7e09..6f320cf 100644
--- a/properties.admin.inc
+++ b/properties.admin.inc
@@ -90,6 +90,11 @@ function properties_admin_attributes_list($form, $form_state) {
     '#title' => t('Search'),
     '#title_display' => 'invisible',
     '#size' => 20,
+  );
+
+  $form['filter']['submit'] = array(
+    '#type' => 'button',
+    '#value' => t('Search'),
     '#ajax' => array(
       'callback' => 'properties_admin_attributes_list_js',
       'wrapper' => 'attributes-list',
@@ -98,11 +103,6 @@ function properties_admin_attributes_list($form, $form_state) {
     ),
   );
 
-  $form['filter']['submit'] = array(
-    '#type' => 'submit',
-    '#value' => t('Search'),
-  );
-
   $form['filter']['reset'] = array(
     '#type' => 'submit',
     '#value' => t('Reset'),
@@ -171,6 +171,7 @@ function properties_admin_attributes_form($form, &$form_state, $attribute = NULL
     '#disabled' => !empty($attribute->name),
     '#machine_name' => array(
       'exists' => 'properties_attribute_load',
+      'source' => array('label'),
     ),
     '#description' => t('A unique machine-readable name for this attribute. It must only contain lowercase letters, numbers, and underscores. This name will be used when using this attribute.'),
   );
@@ -278,6 +279,7 @@ function properties_admin_categories_form($form, &$form_state, $category = NULL)
     '#disabled' => empty($form_state['category']->new),
     '#machine_name' => array(
       'exists' => 'properties_category_load',
+      'source' => array('label'),
     ),
     '#description' => t('A unique machine-readable name for this category. It must only contain lowercase letters, numbers, and underscores. This name will be used when using this attribute.'),
   );
@@ -597,4 +599,4 @@ function properties_admin_categories_delete($form, &$form_state, $category) {
 function properties_admin_categories_delete_submit($form, &$form_state) {
   properties_category_delete($form_state['values']['category']);
   drupal_set_message(t('Category deleted.'));
-}
\ No newline at end of file
+}
diff --git a/properties.module b/properties.module
index 6f18df0..7a50e73 100644
--- a/properties.module
+++ b/properties.module
@@ -1,5 +1,9 @@
 <?php
 
+/**
+ * @file
+ * This module provides a dynamic property field that can contain an unlimited number of attribute value pairs.
+ */
 
 /**
  * Implements hook_permission().
@@ -177,6 +181,110 @@ function properties_theme() {
 }
 
 /**
+ * Process variables for properties-properties-form.tpl.php
+ *
+ * @see properties-properties-form.tpl.php
+ */
+function template_preprocess_properties_properties_form(&$variables) {
+  $element = &$variables['element'];
+  $table_id = $element['#properties_table_id'];
+
+  if (user_access('add properties attributes')) {
+    $header = array(
+      t('Attribute name'),
+      t('Attribute label'),
+      t('Value'),
+      t('Category'),
+      t('Order'),
+      t('Delete'),
+    );
+  }
+  else {
+    $header = array(
+      t('Attribute'),
+      t('Value'),
+    );
+    if (user_access('add properties categories')) {
+      $header[] = t('Order');
+    }
+  }
+  $rows = array();
+  if (user_access('add properties attributes') || user_access('add properties categories')) {
+    drupal_add_tabledrag($table_id, 'match', 'parent', 'property-category-select', 'property-category-select', 'category-name');
+    drupal_add_tabledrag($table_id, 'order', 'sibling', 'property-weight');
+  }
+
+  foreach (element_children($element['listing']) as $category_name) {
+    $category = $element['listing'][$category_name];
+    $category['_weight']['#attributes']['class'] = array('property-weight');
+    $category['name']['#attributes']['class'] = array('category-name');
+    $category['category']['#attributes']['class'] = array('property-category-select');
+
+    $cells = array();
+    $cells[] = '<strong>' . $category['#label'] . '</strong>';
+    $cells[] = '&nbsp;';
+    if (user_access('add properties attributes')) {
+      $cells[] = '&nbsp;';
+      $cells[] = '&nbsp;';
+    }
+    if (user_access('add properties categories')) {
+      $cells[] = drupal_render($category['category']) . drupal_render($category['name']) . drupal_render($category['_weight']);
+      $cells[] = drupal_render($category['delete']);
+    }
+    $rows[] = array(
+      'data' => $cells,
+      'class' => array('draggable', 'tabledrag-root'),
+    );
+
+    foreach (element_children($category['properties']) as $delta) {
+      $property = $category['properties'][$delta];
+
+      // Set special classes needed for table drag and drop.
+      $property['category']['#attributes']['class'] = array('property-category-select');
+      $property['_weight']['#attributes']['class'] = array('property-weight');
+
+      $cells = array();
+      if (user_access('add properties attributes')) {
+        $cells[] = array('data' => theme('indentation', array('size' => 1)) . drupal_render($property['attribute']), 'class' => array('properties-attribute-row-small'));
+        $cells[] = drupal_render($property['label']);
+      }
+      else {
+        $cells[] = theme('indentation', array('size' => 1)) . drupal_render($property['label']);
+      }
+
+      $cells[] = drupal_render($property['value']);
+      if (user_access('add properties attributes')) {
+        $cells[] = drupal_render($property['category']);
+        $cells[] = drupal_render($property['_weight']);
+        $cells[] = drupal_render($property['delete']);
+      }
+      elseif (user_access('add properties categories')) {
+        $cells[] = '&nbsp;';
+      }
+      $rows[] = array(
+        'data' => $cells,
+        'class' => user_access('add properties attributes') ? array('draggable', 'tabledrag-leaf') : array('properties-tabledrag-children'),
+      );
+    }
+  }
+
+  $variables['table'] = theme('table',
+    array(
+      'header' => $header,
+      'rows' => $rows,
+      'attributes' => array(
+        'id' => $table_id,
+        'class' => array('properties-table'),
+      ),
+      'empty' => t('Add properties to this content. Start by adding categories to it.'),
+    ));
+
+  $variables['actions'] = drupal_render($element['actions']);
+
+  $variables['theme_hook_suggestions'][] = 'properties-properties-form__' . $table_id;
+}
+
+/**
  * Check access to an administration page.
  *
  * @param $type
@@ -318,8 +426,6 @@ function properties_field_formatter_info() {
   );
 }
 
-
-
 /**
  * Implements hook_field_widget_info().
  */
@@ -348,7 +454,7 @@ function properties_empty_attribute() {
 }
 
 /**
- * Implements hook_field_widet_form().
+ * Implements hook_field_widget_form().
  */
 function properties_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) {
   $elements = array();
@@ -523,7 +629,6 @@ function properties_field_widget_form(&$form, &$form_state, $field, $instance, $
     '#type' => 'fieldset',
     '#theme' => 'properties_properties_form',
     '#title' => t('Properties'),
-    '#description' => t('Add properties to this content. Start by adding categories to it.'),
     '#prefix' => '<div id="' . $id . '">',
     '#suffix' => '</div>',
     '#max_delta' => $delta,
diff --git a/properties_compare/properties_compare.module b/properties_compare/properties_compare.module
index a40ffaa..5f72b6e 100644
--- a/properties_compare/properties_compare.module
+++ b/properties_compare/properties_compare.module
@@ -30,7 +30,7 @@ function properties_compare_menu() {
   $items['properties/compare/delete/%/%'] = array(
     'title' => 'Delete from compare list',
     'page callback' => 'properties_compare_delete',
-    'page arguments' => array(3,4),
+    'page arguments' => array(3, 4),
     'file' => 'properties_compare.pages.inc',
     'access arguments' => array('compare properties'),
     'type' => MENU_CALLBACK,
@@ -436,4 +436,4 @@ function properties_compare_entity_info() {
     );
   }
   return $return;
-}
\ No newline at end of file
+}
diff --git a/properties_compare/properties_compare.pages.inc b/properties_compare/properties_compare.pages.inc
index 45f5bae..f9aa118 100644
--- a/properties_compare/properties_compare.pages.inc
+++ b/properties_compare/properties_compare.pages.inc
@@ -117,4 +117,4 @@ function properties_compare_page() {
 function properties_compare_delete($entity_type, $entity_id) {
   properties_compare_list_delete($entity_type, $entity_id);
   drupal_goto();
-}
\ No newline at end of file
+}
diff --git a/properties_compare/properties_compare.test b/properties_compare/properties_compare.test
index 98510c8..16f54f6 100644
--- a/properties_compare/properties_compare.test
+++ b/properties_compare/properties_compare.test
@@ -82,7 +82,7 @@ class PropertiesCompareTestCase extends PropertiesBaseTestCase {
     $patterns[] = t('Attributes');
     $patterns[] = $first_node->title;
     $patterns[] = $second_node->title;
-    $current_category = null;
+    $current_category = NULL;
     foreach ($first_node->{'field_' . $this->field_name}['und'] as $key => $item) {
       // Add the label of the category to the pattern if it changed.
       if (!$current_category || $item['category'] != $current_category->name) {
@@ -100,4 +100,4 @@ class PropertiesCompareTestCase extends PropertiesBaseTestCase {
     $pattern = '/' . implode('.*', $patterns) . '/s';
     $this->assertPattern($pattern, t('Comparison table content displayed in correct order.'));
   }
-}
\ No newline at end of file
+}
diff --git a/properties_sql/properties_sql.module b/properties_sql/properties_sql.module
index c960bf2..4114947 100644
--- a/properties_sql/properties_sql.module
+++ b/properties_sql/properties_sql.module
@@ -1,6 +1,5 @@
 <?php
 
-
 /**
  * Save an attribute object.
  *
@@ -11,7 +10,7 @@ function properties_sql_properties_attribute_save($attribute) {
   db_merge('properties_attribute')
     ->key(array('name' => $attribute->name))
     ->fields(array(
-        'label' => $attribute->label,
+      'label' => $attribute->label,
     ))
     ->execute();
 }
@@ -203,7 +202,6 @@ function properties_sql_properties_category_load_paging($per_page, array $option
     ->fetchAllAssoc('name');
 }
 
-
 /**
  * Save a template object.
  *
@@ -235,7 +233,6 @@ function properties_sql_properties_template_save($template) {
   $insert->execute();
 }
 
-
 /**
  * Delete a Template.
  *
@@ -252,8 +249,6 @@ function properties_sql_properties_template_delete($template) {
     ->execute();
 }
 
-
-
 /**
  * Load a template based on the name.
  *
@@ -265,7 +260,6 @@ function properties_sql_properties_template_load($name) {
   return reset($templates);
 }
 
-
 /**
  * Load multiple templates based on their names.
  *
@@ -325,4 +319,4 @@ function properties_sql_properties_template_load_paging($per_page, array $option
   return $query
     ->execute()
     ->fetchAllAssoc('name');
-}
\ No newline at end of file
+}
diff --git a/properties_sql/properties_sql.test b/properties_sql/properties_sql.test
index 0db023a..47a918c 100644
--- a/properties_sql/properties_sql.test
+++ b/properties_sql/properties_sql.test
@@ -1,6 +1,6 @@
 <?php
 
 /**
- * This module is tested with the tests from the properties module.
+ * @file
+ *   This module is tested with the tests from the properties module.
  */
-
diff --git a/properties_template/properties_template.admin.inc b/properties_template/properties_template.admin.inc
index 36ab19c..680098b 100644
--- a/properties_template/properties_template.admin.inc
+++ b/properties_template/properties_template.admin.inc
@@ -1,6 +1,5 @@
 <?php
 
-
 /**
  * @file
  * Contains admin menu callbacks for properties_template.module.
@@ -11,16 +10,16 @@
  */
 function properties_template_admin_templates_list() {
   $header = array(
-      array(
-          'data' => t('Name'),
-          'field' => 'name',
-      ),
-      array(
-          'data' => t('Label'),
-          'field' => 'label',
-          'sort' => 'asc',
-      ),
-      t('Operations'),
+    array(
+      'data' => t('Name'),
+      'field' => 'name',
+    ),
+    array(
+      'data' => t('Label'),
+      'field' => 'label',
+      'sort' => 'asc',
+    ),
+    t('Operations'),
   );
   $templates = properties_template_load_paging(20, array('header' => $header));
   $rows = array();
@@ -29,9 +28,9 @@ function properties_template_admin_templates_list() {
     $links = array(l(t('edit'), 'admin/config/content/properties/templates/edit/' . $template->name, $url_options), l(t('delete'), 'admin/config/content/properties/templates/delete/' . $template->name, $url_options));
 
     $rows[] = array(
-        check_plain($template->name),
-        check_plain($template->label),
-        implode(' ', $links),
+      check_plain($template->name),
+      check_plain($template->label),
+      implode(' ', $links),
     );
   }
   return theme('table', array('rows' => $rows, 'header' => $header, 'empty' => t('No templates found.')));
@@ -44,10 +43,10 @@ function properties_template_admin_templates_form($form, &$form_state, $template
   if (!isset($form_state['template'])) {
     if (isset($_GET['entity_type'])) {
       $template = (object) array(
-          'label' => '',
-          'name' => '',
-          'categories' => array(),
-          'new' => TRUE,
+        'label' => '',
+        'name' => '',
+        'categories' => array(),
+        'new' => TRUE,
       );
 
       $entity_type = $_GET['entity_type'];
@@ -76,12 +75,13 @@ function properties_template_admin_templates_form($form, &$form_state, $template
           }
         }
       }
-    } else if (empty($template) || !is_object($template)) {
+    }
+    elseif (empty($template) || !is_object($template)) {
       $template = (object) array(
-          'label' => '',
-          'name' => '',
-          'categories' => array(),
-          'new' => TRUE,
+        'label' => '',
+        'name' => '',
+        'categories' => array(),
+        'new' => TRUE,
       );
     }
     $form_state['template'] = $template;
@@ -98,31 +98,31 @@ function properties_template_admin_templates_form($form, &$form_state, $template
   if ($add_empty) {
     // Use a random id for these to trick out browsers.
     $form_state['template']->categories[] = (object) array(
-        'name' => '',
-        'label' => '',
-        'weight' => count($form_state['template']->categories),
+      'name' => '',
+      'label' => '',
+      'weight' => count($form_state['template']->categories),
     );
   }
 
   drupal_add_css(drupal_get_path('module', 'properties') . '/properties_admin.css');
 
   $form['label'] = array(
-      '#title' => t('Template label'),
-      '#type' => 'textfield',
-      '#default_value' => $form_state['template']->label,
-      '#maxlength' => 255,
-      '#required' => TRUE,
+    '#title' => t('Template label'),
+    '#type' => 'textfield',
+    '#default_value' => $form_state['template']->label,
+    '#maxlength' => 255,
+    '#required' => TRUE,
   );
 
   $form['name'] = array(
-      '#type' => 'machine_name',
-      '#default_value' => $form_state['template']->name,
-      '#maxlength' => 32,
-      '#disabled' => empty($form_state['template']->new),
-      '#machine_name' => array(
-          'exists' => 'properties_template_load',
-      ),
-      '#description' => t('A unique machine-readable name for this category. It must only contain lowercase letters, numbers, and underscores. This name will be used when using this category.'),
+    '#type' => 'machine_name',
+    '#default_value' => $form_state['template']->name,
+    '#maxlength' => 32,
+    '#disabled' => empty($form_state['template']->new),
+    '#machine_name' => array(
+      'exists' => 'properties_template_load',
+    ),
+    '#description' => t('A unique machine-readable name for this category. It must only contain lowercase letters, numbers, and underscores. This name will be used when using this category.'),
   );
 
   $categories = array();
@@ -137,9 +137,9 @@ function properties_template_admin_templates_form($form, &$form_state, $template
         '#default_value' => $category->name,
         '#autocomplete_path' => 'properties_autocomplete/category',
         '#ajax' => array(
-            'callback' => 'properties_admin_update_label_js',
-            'wrapper' => 'attributes-wrapper',
-            'effect' => 'fade',
+          'callback' => 'properties_admin_update_label_js',
+          'wrapper' => 'attributes-wrapper',
+          'effect' => 'fade',
         ),
     );
     // TODO: add categories-wrapper
@@ -150,59 +150,60 @@ function properties_template_admin_templates_form($form, &$form_state, $template
     // We name the element '_weight' to avoid clashing with elements
     // defined by widget.
     $element['_weight'] = array(
-        '#type' => 'weight',
-        '#title' => t('Weight for row @number', array('@number' => $delta)),
-        '#title_display' => 'invisible',
-        '#default_value' => $delta,
-        '#weight' => 100,
+      '#type' => 'weight',
+      '#title' => t('Weight for row @number', array('@number' => $delta)),
+      '#title_display' => 'invisible',
+      '#default_value' => $delta,
+      '#weight' => 100,
     );
     $categories[!empty($category->name) ? $category->name : $delta] = $element;
     $delta++;
   }
 
   $categories += array(
-      '#type' => 'fieldset',
-      '#theme' => 'properties_template_admin_templates_categories_form',
-      '#title' => t('Categories'),
-      '#description' => t('Configure the default categories of this template.'),
-      '#prefix' => '<div id="attributes-wrapper">',
-      '#suffix' => '</div>',
-      '#max_delta' => $delta,
-      '#tree' => TRUE,
+    '#type' => 'fieldset',
+    '#theme' => 'properties_template_admin_templates_categories_form',
+    '#title' => t('Categories'),
+    '#description' => t('Configure the default categories of this template.'),
+    '#prefix' => '<div id="attributes-wrapper">',
+    '#suffix' => '</div>',
+    '#max_delta' => $delta,
+    '#tree' => TRUE,
   );
   $categories['add_more'] = array(
-      '#type' => 'submit',
-      '#name' => 'categories_add_more',
-      '#value' => t('Add another category'),
-      '#categories' => array('class' => array('field-add-more-submit')),
-      '#limit_validation_errors' => array(array('categories')),
-      '#submit' => array('properties_template_admin_add_more_submit'),
-      '#ajax' => array(
-          'callback' => 'properties_template_admin_add_more_js',
-          'wrapper' => 'attributes-wrapper',
-          'effect' => 'fade',
-      ),
+    '#type' => 'submit',
+    '#name' => 'categories_add_more',
+    '#value' => t('Add another category'),
+    '#categories' => array('class' => array('field-add-more-submit')),
+    '#limit_validation_errors' => array(array('categories')),
+    '#submit' => array('properties_template_admin_add_more_submit'),
+    '#ajax' => array(
+      'callback' => 'properties_template_admin_add_more_js',
+      'wrapper' => 'attributes-wrapper',
+      'effect' => 'fade',
+    ),
   );
 
   $form['categories'] = $categories;
 
   if (empty($template->name)) {
     $form['add'] = array(
-        '#value' => t('Save'),
-        '#type' => 'submit',
-        '#submit' => array('properties_template_admin_templates_add'),
+      '#value' => t('Save'),
+      '#type' => 'submit',
+      '#submit' => array('properties_template_admin_templates_add'),
     );
 
     $form['add_another'] = array(
-        '#value' => t('Save and add another'),
-        '#type' => 'submit',
-        '#submit' => array('properties_template_admin_templates_add_another'),
+      '#value' => t('Save and add another'),
+      '#type' => 'submit',
+      '#submit' => array('properties_template_admin_templates_add_another'),
     );
-  } else {
+  }
+  else {
     $form['save'] = array(
-        '#value' => t('Save'),
-        '#type' => 'submit',
-        '#submit' => array('properties_template_admin_templates_save'),
+      '#value' => t('Save'),
+      '#type' => 'submit',
+      '#submit' => array('properties_template_admin_templates_save'),
     );
   }
   return $form;
@@ -221,15 +222,17 @@ function properties_template_admin_templates_form_validate($form, &$form_state)
     if (is_array($category) && isset($category['category'])) {
       if (empty($category['category'])) {
         $category_object = (object) array(
-            'label' => '',
-            'name' => '',
-            'weight' => count($form_state['template']->categories),
+          'label' => '',
+          'name' => '',
+          'weight' => count($form_state['template']->categories),
         );
         $form_state['template']->categories[$name] = $category_object;
-      } elseif ($category_object = properties_category_load($category['category'])) {
+      }
+      elseif ($category_object = properties_category_load($category['category'])) {
         $category_object->weight = count($form_state['template']->categories);
         $form_state['template']->categories[$category_object->name] = $category_object;
-      } else {
+      }
+      else {
         // Update empty category.
         $form_state['template']->categories[$category['category']]->name = $category['category'];
         $form_state['template']->categories[$category['category']]->label = isset($category['label']) ? $category['label'] : '';
@@ -299,15 +302,13 @@ function properties_template_admin_templates_add_another($form, &$form_state) {
  */
 function properties_template_admin_add_more_submit($form, &$form_state) {
   $form_state['template']->categories[] = (object) array(
-      'label' => '',
-      'name' => '',
-      'weight' => count($form_state['template']->categories),
+    'label' => '',
+    'name' => '',
+    'weight' => count($form_state['template']->categories),
   );
 
   foreach ($form_state['template']->categories as $name => $category) {
-
     if (is_int($name)) {
-
       unset($form_state['input']['categories'][$name]);
     }
   }
@@ -320,8 +321,8 @@ function properties_template_admin_add_more_submit($form, &$form_state) {
  */
 function properties_template_admin_templates_delete($form, &$form_state, $template) {
   $form['template'] = array(
-      '#type' => 'value',
-      '#value' => $template,
+    '#type' => 'value',
+    '#value' => $template,
   );
 
   return confirm_form($form, t('Delete template %template', array('%template' => $template->label)), '');
@@ -353,13 +354,13 @@ function theme_properties_template_admin_templates_categories_form($variables) {
   $required = !empty($element['#required']) ? '<span class="form-required" title="' . t('This field is required.') . '">*</span>' : '';
 
   $header = array(
-      array(
-          'data' => '<label>' . t('!title: !required', array('!title' => $element['#title'], '!required' => $required)) . "</label>",
-          'colspan' => 2,
-          'class' => array('field-label'),
-      ),
-      t('Label'),
-      t('Order'),
+    array(
+      'data' => '<label>' . t('!title: !required', array('!title' => $element['#title'], '!required' => $required)) . "</label>",
+      'colspan' => 2,
+      'class' => array('field-label'),
+    ),
+    t('Label'),
+    t('Order'),
   );
   $rows = array();
 
@@ -369,7 +370,8 @@ function theme_properties_template_admin_templates_categories_form($variables) {
   foreach (element_children($element) as $key) {
     if ($key === 'add_more') {
       $add_more_button = &$element[$key];
-    } else {
+    }
+    else {
       $items[] = &$element[$key];
     }
   }
@@ -382,14 +384,14 @@ function theme_properties_template_admin_templates_categories_form($variables) {
 
     $label = drupal_render($item['label']);
     $cells = array(
-        array('data' => '', 'class' => array('field-multiple-drag')),
-        array('data' => drupal_render($item), 'class' => array('properties-category-row-small')),
-        $label,
-        array('data' => $delta_element, 'class' => array('delta-order')),
+      array('data' => '', 'class' => array('field-multiple-drag')),
+      array('data' => drupal_render($item), 'class' => array('properties-category-row-small')),
+      $label,
+      array('data' => $delta_element, 'class' => array('delta-order')),
     );
     $rows[] = array(
-        'data' => $cells,
-        'class' => array('draggable'),
+      'data' => $cells,
+      'class' => array('draggable'),
     );
   }
 
diff --git a/properties_template/properties_template.module b/properties_template/properties_template.module
index 7432c37..5913206 100644
--- a/properties_template/properties_template.module
+++ b/properties_template/properties_template.module
@@ -156,7 +156,6 @@ function properties_template_delete($template) {
  */
 function properties_template_field_attach_form($entity_type, $entity, &$form, &$form_state, $langcode) {
 
-
   // Load fields attached to the entity.
   $fields = field_info_instances($form['#entity_type'], $form['#bundle']);
 
@@ -175,7 +174,7 @@ function properties_template_field_attach_form($entity_type, $entity, &$form, &$
 
         // Bail out if permissions are missing.
         if (!user_access('add properties templates')) {
-           return;
+          return;
         }
 
         // Prepare options for select.
@@ -204,13 +203,14 @@ function properties_template_field_attach_form($entity_type, $entity, &$form, &$
           ),
         );
         $form[$field_name][$langcode]['actions'] += $element;
-      } else {
+      }
+      else {
 
         // Bail out if permissions are missing.
         if (!user_access('administer properties templates')) {
-           return;
+          return;
         }
-        
+
         list($entity_id, , ) = entity_extract_ids($entity_type, $entity);
         $query = array('entity_type' => $entity_type, 'entity_id' => $entity_id, 'field_name' => $field_name);
 
@@ -224,7 +224,6 @@ function properties_template_field_attach_form($entity_type, $entity, &$form, &$
           '#options' => array('query' => $query),
         );
         $form[$field_name][$langcode]['actions'] += $element;
-
       }
     }
   }
diff --git a/properties_template/properties_template.test b/properties_template/properties_template.test
index 8614b25..3846040 100644
--- a/properties_template/properties_template.test
+++ b/properties_template/properties_template.test
@@ -170,7 +170,7 @@ class PropertiesTemplateTestCase extends PropertiesTemplateBaseTestCase {
     $template = $this->createTemplate(NULL, NULL, $this->categories);
 
     $this->loginTemplateUser();
-    
+
     // Verify that buttons to add attributes and categories don't exist.
     $this->drupalGet('node/add/page');
 
