diff --git a/reply.field.inc b/reply.field.inc
index b2dba66..0a82b4f 100644
--- a/reply.field.inc
+++ b/reply.field.inc
@@ -192,7 +192,7 @@ function reply_field_formatter_view($entity_type, $entity, $field, $instance, $l
   }

   $element['#attached']['css'] = array(
-    drupal_get_path('module', 'reply') .'/reply.css'
+    drupal_get_path('module', 'reply') . '/reply.css'
   );

   return $element;
diff --git a/reply.module b/reply.module
index 2d014e9..a395632 100644
--- a/reply.module
+++ b/reply.module
@@ -21,7 +21,7 @@ define('REPLY_DELETE_ALL', 2);
 require_once 'reply.field.inc';

 /**
- * _init
+ * Implements hook_init().
  */
 function reply_init() {
   // Deny editing fields for locked bundles
@@ -35,7 +35,7 @@ function reply_init() {
 }

 /**
- *  _menu
+ * Implements hook_menu().
  */
 function reply_menu() {
   $items = array();
@@ -122,6 +122,7 @@ function reply_menu() {
       'weight' => 100,
     );
   }
+
   $items['reply/add/%/%/%'] = array(
     'title' => 'Reply',
     'page callback' => 'reply_post',
@@ -140,7 +141,7 @@ function reply_menu() {
     'type' => MENU_CALLBACK,
     'delivery callback' => 'ajax_deliver',
   );
-
+
   $items['reply/add/%/%/%/nojs'] = array(
     'title' => 'Reply',
     'page callback' => '_ajax_add_reply',
@@ -149,7 +150,7 @@ function reply_menu() {
     'access arguments' => array('create', 3, NULL, 2),
     'type' => MENU_CALLBACK,
   );
-
+
   $items['admin/content/reply'] = array(
     'title' => 'Replies',
     'page callback' => 'reply_page_list',
@@ -179,7 +180,7 @@ function reply_admin_menu_map() {


 /**
- * _permission
+ * Implements hook_permission().
  */
 function reply_permission() {
   $out = array(
@@ -222,7 +223,7 @@ function reply_permission() {


 /**
- * _theme
+ * Implements hook_theme().
  */
 function reply_theme() {
   return array(
@@ -230,10 +231,6 @@ function reply_theme() {
       'render element' => 'elements',
       'template' => 'replies'
     ),
-    'reply' => array(
-      'render element' => 'elements',
-      'template' => 'reply'
-    ),
     'reply_post_forbidden' => array(
       'variables' => array('entity' => NULL, 'entity_type' => NULL, 'instance_id' => NULL, 'form' => NULL, 'bundle' => NULL),
     ),
@@ -242,7 +239,7 @@ function reply_theme() {


 /**
- *  _entity_info()
+ * Implements hook_entity_info()
  */
 function reply_entity_info() {
   $return = array(
@@ -313,7 +310,7 @@ function reply_entity_info_alter(&$info) {
       'admin' => array(
         'path' => 'admin/structure/reply/manage/%reply_bundle',
         'bundle argument' => 4,
-        'real path' => 'admin/structure/reply/manage/'. $bundle->bundle,
+        'real path' => 'admin/structure/reply/manage/' . $bundle->bundle,
         'access arguments' => array('administer reply bundles'),
       ),
     );
@@ -429,7 +426,7 @@ function reply_label(&$entity) {
  */
 function reply_uri(&$entity) {
   return array(
-    'path' => 'reply/'. $entity->id
+    'path' => 'reply/' . $entity->id
   );
 }

@@ -504,7 +501,6 @@ function reply_delete_multiple($ids, $op = REPLY_DELETE_REPLACE) {
  *
  * @param $reply object
  *    The entity object that is about to be deleted.
-
  */
 function reply_positions_delete($reply) {
   db_update('reply')
@@ -540,7 +536,8 @@ function reply_save($entity) {
   // We validate Field API fields before saving into database.
   try {
     field_attach_validate('reply', $entity);
-  } catch (FieldValidationException $e) {
+  }
+  catch (FieldValidationException $e) {
     return FALSE;
   }

@@ -672,14 +669,15 @@ function reply_load_user($uid) {
 function reply_get_children($id, $recursive = FALSE) {
   if (!$recursive) {
     return db_select('reply', 'r')->fields('r', array('id'))->condition('parent', $id)->orderBy('created')->execute()->fetchCol();
-  } else {
+  }
+  else {
     $parent = db_select('reply', 'r')
       ->fields('r', array('id', 'depth', 'entity_id', 'entity_type', 'instance_id', 'bundle'))
       ->condition('id', $id)
       ->execute()
       ->fetchObject();

-    $maxDepth = db_select('reply', 'r')
+    $maxdepth = db_select('reply', 'r')
       ->fields('r', array('depth'))
       ->condition('instance_id', $parent->instance_id)
       ->condition('entity_id', $parent->entity_id)
@@ -690,7 +688,7 @@ function reply_get_children($id, $recursive = FALSE) {
       ->execute()
       ->fetchField();

-    if ($maxDepth == $parent->depth) {
+    if ($maxdepth == $parent->depth) {
       return FALSE;
     }

@@ -705,11 +703,11 @@ function reply_get_children($id, $recursive = FALSE) {
     }

     $buffer = array();
-    $startDepth = $parent->depth;
-    $startDepth++;
-    $buffer[$startDepth] = $children;
+    $startdepth = $parent->depth;
+    $startdepth++;
+    $buffer[$startdepth] = $children;

-    for ($i = $startDepth; $i <= $maxDepth; $i++) {
+    for ($i = $startdepth; $i <= $maxdepth; $i++) {
       if (isset($buffer[$i])) {
         foreach ($buffer[$i] AS $chid) {
           $n = $i;
@@ -721,7 +719,8 @@ function reply_get_children($id, $recursive = FALSE) {
             ->fetchCol();
           if ($data) {
             $buffer[$n] = $data;
-          } else {
+          }
+          else {
             break;
           }
         }
@@ -729,7 +728,7 @@ function reply_get_children($id, $recursive = FALSE) {
     }

     $return = array();
-    foreach ($buffer AS $list) {
+    foreach ($buffer as $list) {
       $return = array_merge($return, $list);
     }

@@ -805,25 +804,27 @@ function template_preprocess_replies(&$vars) {
   $vars = array_merge($vars, $vars['elements']);
   $vars['replies'] = array();

-  if ($vars['access'] <> REPLY_ACCESS_NONE && !empty($vars['elements']['replies']) && (user_access('administer replies') || user_access('view '. $vars['bundle'] .' reply'))) {
+  if ($vars['access'] <> REPLY_ACCESS_NONE && !empty($vars['elements']['replies']) && (user_access('administer replies') || user_access('view ' . $vars['bundle'] . ' reply'))) {
     foreach ($vars['elements']['replies'] AS $reply) {
-      $vars['replies'][$reply->id]['#markup'] = theme('reply', array('elements' => array('reply' => $reply, 'display' => $vars['display'], 'access' => $vars['access'], 'allow_reply' => $vars['allow_reply'], 'bundle' => $vars['bundle'])));
+      $vars['replies'][$reply->id] = reply_view($reply);
+      $vars['replies'][$reply->id]['#access'] = $vars['access'];
     }
   }

   $vars['reply_form'] = '';
   $vars['links'] = '';
-  if (($vars['access'] == REPLY_ACCESS_FULL && user_access('administer replies')) ||  user_access('administer replies') || user_access('post '. $vars['bundle'] .' reply')) {
-      if ($vars['form'] == REPLY_FORM_PAGE_SAME) {
-          $vars['reply_form'] = drupal_get_form('reply_add_form_'. $vars['entity_id'] .'_'. $vars['instance_id'], $vars['entity_id'], $vars['instance_id'], 0);
-      }
+  if (($vars['access'] == REPLY_ACCESS_FULL && user_access('administer replies')) ||  user_access('administer replies') || user_access('post ' . $vars['bundle'] . ' reply')) {
+    if ($vars['form'] == REPLY_FORM_PAGE_SAME) {
+      $vars['reply_form'] = drupal_get_form('reply_add_form_' . $vars['entity_id'] . '_' . $vars['instance_id'], $vars['entity_id'], $vars['instance_id'], 0);
+    }

-      if ($vars['form'] == REPLY_FORM_PAGE_CUSTOM) {
-          $vars['links']['add_reply']['#markup'] = l(t('Add reply'), 'reply/add/'. $vars['entity_id'] .'/'. $vars['instance_id'] .'/0');
-      }
-  } else {
+    if ($vars['form'] == REPLY_FORM_PAGE_CUSTOM) {
+      $vars['links']['add_reply']['#markup'] = l(t('Add reply'), 'reply/add/' . $vars['entity_id'] . '/' . $vars['instance_id'] . '/0');
+    }
+  }
+  else {
      $vars['links']['reply_post_forbidden'] = array(
-         '#markup' => theme('reply_post_forbidden', array('entity_type' => $vars['entity_type'], 'entity'=>$vars['entity'],'instance_id' => $vars['instance_id'], 'form'=>$vars['form'], 'bundle' => $vars['bundle'])),
+       '#markup' => theme('reply_post_forbidden', array('entity_type' => $vars['entity_type'], 'entity' => $vars['entity'], 'instance_id' => $vars['instance_id'], 'form' => $vars['form'], 'bundle' => $vars['bundle'])),
      );
   }
 }
@@ -834,54 +835,51 @@ function template_preprocess_replies(&$vars) {
  * which relates to the reply
  */
 function reply_forms($form_id, $args) {
-    $forms = array();
+  $forms = array();

-    if (stripos($form_id, 'reply_add_form') === 0) {
-        $forms[$form_id] = array(
-            'callback' => 'reply_add_form',
-        );
-    }
+  if (stripos($form_id, 'reply_add_form') === 0) {
+    $forms[$form_id] = array(
+      'callback' => 'reply_add_form',
+    );
+  }

-    return $forms;
+  return $forms;
 }

 /**
  * _preprocess_reply
  */
-function template_preprocess_reply(&$vars) {
-  $vars = array_merge($vars, $vars['elements']);
-  if (!isset($vars['reply'])) {
-    $vars['reply'] = $vars['#reply'];
+function reply_preprocess_entity(&$vars) {
+  if ($vars['entity_type'] !== 'reply') {
+    return;
   }
-  $reply = $vars['reply'];
+
+  $reply = $vars['elements']['#entity'];

   if ($reply->uid == 0) {
     $vars['author'] = variable_get('anonymous', t('Anonymous'));
-  } else {
-    $replyUser = user_load($reply->uid);
-    $vars['author'] = theme('username', array('account' => $replyUser));
+  }
+  else {
+    $replyuser = user_load($reply->uid);
+    $vars['author'] = theme('username', array('account' => $replyuser));
   }

   $vars['created'] = format_date($reply->created, 'medium');
   $vars['changed'] = format_date($reply->changed, 'medium');

   if (isset($vars['elements']['display']) && $vars['elements']['display'] == REPLY_LIST_TREE) {
-    $vars['classes_array'][] = 'push-'. $reply->depth;
+    $vars['classes_array'][] = 'push-' . $reply->depth;
   }

-  $vars['entity_id'] = $reply->entity_id;
-  $vars['entity_type'] = $reply->entity_type;
-
-  $vars['links'] = '';
+  $vars['links'] = array();
   // Load settings for this entity
   $settings = _reply_get_settings($reply);

-  //$settings = reply_load_instance($reply->instance_id);
-  if (isset($vars['access']) && $vars['access'] == REPLY_ACCESS_FULL) {
+  if (isset($vars['elements']['#access']) && $vars['elements']['#access'] == REPLY_ACCESS_FULL) {
     if (reply_access('reply', $reply)) {
       if ($settings['form'] == REPLY_FORM_PAGE_SAME) {
         $vars['links']['reply']['#markup'] = l(t('Reply'), 'reply/add/' . $reply->entity_id . '/' . $reply->instance_id . '/' . $reply->id . '/nojs', array('attributes' => array('class' => array('use-ajax')), 'query' => array('destination' => $_GET['q'])));
-      }
+      }
       else {
         $vars['links']['reply']['#markup'] = l(t('Reply'), 'reply/add/' . $reply->entity_id . '/' . $reply->instance_id . '/' . $reply->id);
       }
@@ -890,7 +888,7 @@ function template_preprocess_reply(&$vars) {
     if (reply_access('update', $reply)) {
       if ($settings['form'] == REPLY_FORM_PAGE_SAME) {
         $vars['links']['edit']['#markup'] = l(t('Edit'), 'reply/' . $reply->id . '/edit/nojs', array('attributes' => array('class' => array('use-ajax')), 'query' => array('destination' => $_GET['q'])));
-      }
+      }
       else {
         $vars['links']['edit']['#markup'] = l(t('Edit'), 'reply/' . $reply->id . '/edit/nojs', array('query' => array('destination' => $_GET['q'])));
       }
@@ -898,8 +896,8 @@ function template_preprocess_reply(&$vars) {

     if (reply_access('delete', $reply)) {
       if ($settings['form'] == REPLY_FORM_PAGE_SAME) {
-        $vars['links']['delete']['#markup'] = l(t('Delete'), 'reply/' . $reply->id . '/delete/nojs', array('attributes' => array('class'=>array('use-ajax')), 'query' => array('destination' => $_GET['q'])));
-      }
+        $vars['links']['delete']['#markup'] = l(t('Delete'), 'reply/' . $reply->id . '/delete/nojs', array('attributes' => array('class' => array('use-ajax')), 'query' => array('destination' => $_GET['q'])));
+      }
       else {
         $vars['links']['delete']['#markup'] = l(t('Delete'), 'reply/' . $reply->id . '/delete/nojs', array('query' => array('destination' => $_GET['q'])));
       }
@@ -910,8 +908,8 @@ function template_preprocess_reply(&$vars) {
   $vars['permalink'] = l(t('Permalink'), $uri['path'], array('class' => 'permalink', 'rel' => 'bookmark'));
   $vars['submitted'] = t('Submitted by !username on !datetime', array('!username' => $vars['author'], '!datetime' => $vars['created']));

-  field_attach_prepare_view('reply', array($reply->id => $reply), 'full');
-  $vars['content'] = field_attach_view('reply', $reply, 'full');
+  // Helpful $content variable for templates.
+  $vars += array('content' => array());

   if ($reply->deleted == REPLY_DELETED) {
     $bundle = reply_bundle_load($reply->bundle);
@@ -927,49 +925,48 @@ function template_preprocess_reply(&$vars) {
  * @param $reply
  * @return array of reply settings for a reply entity instance.
  */
-function _reply_get_settings($reply)
-{
-    $instance_id = $reply->instance_id;
-    $instance = reply_load_instance($instance_id);
-    $entity_type = $instance->entity_type;
-    $entity = entity_load($entity_type, array($reply->entity_id));
-    $entity = reset($entity);
-    $field_info = field_info_field($instance->field_name);
-    $bundle = $field_info['settings']['bundle'];
-    $entity_settings = field_get_items($entity_type, $entity, $instance->field_name);
-    $entity_settings = empty($entity_settings) ? $instance->data['settings'] : reset($entity_settings);
-    return reply_settings($bundle, $field_info['settings'], $instance->data['settings'], $entity_settings);
+function _reply_get_settings($reply) {
+  $instance_id = $reply->instance_id;
+  $instance = reply_load_instance($instance_id);
+  $entity_type = $instance->entity_type;
+  $entity = entity_load($entity_type, array($reply->entity_id));
+  $entity = reset($entity);
+  $field_info = field_info_field($instance->field_name);
+  $bundle = $field_info['settings']['bundle'];
+  $entity_settings = field_get_items($entity_type, $entity, $instance->field_name);
+  $entity_settings = empty($entity_settings) ? $instance->data['settings'] : reset($entity_settings);
+  return reply_settings($bundle, $field_info['settings'], $instance->data['settings'], $entity_settings);
 }

-function reply_post($entity_id, $instance_id, $parent){
-    $instance = reply_load_instance($instance_id);
-    $entity_type = $instance->entity_type;
-    $entity = entity_load($entity_type, array($entity_id));
-    $entity = reset($entity);
-    $entity_url = '/' . $entity->type . '/' . $entity_id;
-    drupal_set_breadcrumb(array(l(t('Home'), NULL), l($entity->title, $entity_url)));
-    $build = array();
-
-    if ($parent) {
-        $parent_reply = reply_load($parent);
-        if (!$parent_reply) {
-            drupal_set_message(t('The %reply you are replying to does not exist.', array('reply' => $parent_reply->bundle)), 'error');
-            drupal_goto($entity_url);
-        }
-        if (!reply_access('reply', $parent_reply)){
-            drupal_set_message(t('You are not authorized to view this reply.'), 'error');
-            drupal_goto($entity_url);
-        }
-        $build['reply_parent'] = reply_view($parent_reply);
+function reply_post($entity_id, $instance_id, $parent) {
+  $instance = reply_load_instance($instance_id);
+  $entity_type = $instance->entity_type;
+  $entity = entity_load($entity_type, array($entity_id));
+  $entity = reset($entity);
+  $entity_url = '/' . $entity->type . '/' . $entity_id;
+  drupal_set_breadcrumb(array(l(t('Home'), NULL), l($entity->title, $entity_url)));
+  $build = array();
+
+  if ($parent) {
+    $parent_reply = reply_load($parent);
+    if (!$parent_reply) {
+      drupal_set_message(t('The %reply you are replying to does not exist.', array('reply' => $parent_reply->bundle)), 'error');
+      drupal_goto($entity_url);
     }
-    // This is a reply post to an entity, not in response to a reply post, so render the node and the form
-    else {
-        $entities = entity_load($entity_type, array($entity_id));
-        $build['reply_entity'] = entity_view($entity_type, $entities, 'teaser');
+    if (!reply_access('reply', $parent_reply)) {
+      drupal_set_message(t('You are not authorized to view this reply.'), 'error');
+      drupal_goto($entity_url);
     }
-    $build['reply_form'] = drupal_get_form('reply_add_form', $entity_id, $instance_id, $parent);
+    $build['reply_parent'] = reply_view($parent_reply);
+  }
+  // This is a reply post to an entity, not in response to a reply post, so render the node and the form
+  else {
+    $entities = entity_load($entity_type, array($entity_id));
+    $build['reply_entity'] = entity_view($entity_type, $entities, 'teaser');
+  }
+  $build['reply_form'] = drupal_get_form('reply_add_form', $entity_id, $instance_id, $parent);

-    return $build;
+  return $build;

 }

@@ -1009,7 +1006,8 @@ function reply_add_form($form, &$form_state, $entity_id, $instance_id, $parent =
     $parent = $parent->id;
     // Increase depth level for new entity
     $depth++;
-  } else {
+  }
+  else {
     $depth = 0;
   }

@@ -1026,7 +1024,8 @@ function reply_add_form($form, &$form_state, $entity_id, $instance_id, $parent =
     if ($settings['form'] == REPLY_FORM_PAGE_CUSTOM) {
       //@todo watchdog
       drupal_goto($redirect['path']);
-    } else {
+    }
+    else {
       return;
     }
   }
@@ -1144,7 +1143,8 @@ function reply_add_form_submit($form, &$form_state) {
   // Set redirect
   if (isset($form_state['values']['redirect'])) {
     $redirect = $form_state['values']['redirect'];
-  } else {
+  }
+  else {
     $entity = entity_load($reply->entity_type, array($reply->entity_id));
     $entity = reset($entity);
     $redirect = entity_uri($reply->entity_type, $entity);
@@ -1221,7 +1221,8 @@ function reply_edit_form($form, &$form_state, $reply, $ajax = 'nojs') {
       '#default_value' => $reply->status,
       '#weight' => 100
     );
-  } else {
+  }
+  else {
     $form['status'] = array(
       '#type' => 'value',
       '#value' => $reply->status
@@ -1247,10 +1248,10 @@ function reply_edit_form($form, &$form_state, $reply, $ajax = 'nojs') {
     );
   }
   if ($is_ajax) {
-    $form['buttons']['delete']['#markup'] = l(t('Delete'), 'reply/' . $reply->id . '/delete/nojs', array('attributes' => array('class'=> array('use-ajax')), 'query' => array('destination' => 'node/' . $reply->parent))); // TO FIX
+    $form['buttons']['delete']['#markup'] = l(t('Delete'), 'reply/' . $reply->id . '/delete/nojs', array('attributes' => array('class' => array('use-ajax')), 'query' => array('destination' => 'node/' . $reply->parent))); // TO FIX
   }
   else {
-    $form['buttons']['delete']['#markup'] = l(t('Delete'), 'reply/'. $reply->id .'/delete');
+    $form['buttons']['delete']['#markup'] = l(t('Delete'), 'reply/' . $reply->id . '/delete');
   }
   // Recycle functions
   $form['#validate'] = array('reply_add_form_validate');
@@ -1276,8 +1277,8 @@ function reply_delete_form($form, &$form_state, $reply) {
     '#type' => 'radios',
     '#title' => t('Type'),
     '#options' => array(
-      REPLY_DELETE_ALL => t("Delete entity and it's children"),
-      REPLY_DELETE_REPLACE => t("Delete entity but preserve it's children using placeholder")
+      REPLY_DELETE_ALL => t('Delete entity and its children'),
+      REPLY_DELETE_REPLACE => t('Delete entity but preserve its children using placeholder')
     ),
     '#default_value' => REPLY_DELETE_ALL,
     '#required' => TRUE,
@@ -1309,7 +1310,7 @@ function reply_delete_form($form, &$form_state, $reply) {
  */
 function reply_delete_form_submit($form, &$form_state) {
   reply_delete($form_state['values']['id'], $form_state['values']['type']);
-  $message = t('!bundle was successfully deleted.', array('!bundle' => ucfirst($form_state['values']['bundle'])));
+  $message = t('!bundle was successfully deleted.', array('!bundle' => drupal_ucfirst($form_state['values']['bundle'])));
   drupal_set_message($message);
   $form_state['redirect'] = 'admin/structure/reply';
 }
@@ -1492,8 +1493,8 @@ function reply_view($reply, $entity = NULL, $view_mode = 'full', $langcode = NUL

   $build += array(
     '#theme' => 'reply__' . $reply->bundle,
-    '#reply' => $reply,
-    '#entity' => $entity,
+    '#entity' => $reply,
+    '#attached_to' => reset($entity),
     '#view_mode' => $view_mode,
     '#language' => $langcode,
   );
@@ -1578,7 +1579,8 @@ function reply_bundle_form($form, &$form_state, $bundle = NULL, $op = 'edit') {
       '#type' => 'value',
       '#value' => $bundle->bundle
     );
-  } else {
+  }
+  else {
     $form['bundle'] = array(
       '#type' => 'machine_name',
       '#maxlength' => 64,
@@ -1731,16 +1733,16 @@ function reply_page_list() {
     ->fetchCol();

   $languages = language_list();
-  $loadBundles = reply_load_bundles();
+  $loadbundles = reply_load_bundles();
   $bundles = array();
-  foreach ($loadBundles AS $bundle) {
+  foreach ($loadbundles as $bundle) {
     $bundles[$bundle->bundle] = $bundle->name;
   }
-  unset($loadBundles);
+  unset($loadbundles);

   $rows = array();
   $replies = reply_load_multiple($ids);
-  foreach ($replies AS $reply) {
+  foreach ($replies as $reply) {
     if ($reply->language == LANGUAGE_NONE || isset($languages[$reply->language])) {
       $language = $reply->language == LANGUAGE_NONE ? t('Language neutral') : t($languages[$reply->language]->name);
     }
@@ -1755,9 +1757,9 @@ function reply_page_list() {
     $row[] = format_date($reply->created, 'short');
     $row[] = $bundles[$reply->bundle];
     $row[] = $language;
-    $row[] = l(t('View'), 'reply/'. $reply->id .'/view');
-    $row[] = l(t('Edit'), 'reply/'. $reply->id .'/edit', array('query' => array('destination' => $_GET['q'])));
-    $row[] = l(t('Delete'), 'reply/'. $reply->id .'/delete', array('query' => array('destination' => $_GET['q'])));
+    $row[] = l(t('View'), 'reply/' . $reply->id . '/view');
+    $row[] = l(t('Edit'), 'reply/' . $reply->id . '/edit', array('query' => array('destination' => $_GET['q'])));
+    $row[] = l(t('Delete'), 'reply/' . $reply->id . '/delete', array('query' => array('destination' => $_GET['q'])));
     $rows[] = $row;
   }

@@ -1855,15 +1857,17 @@ function reply_list_filter_form_submit($form, &$form_state) {
 function reply_settings($bundle_settings, $field_settings, $instance_settings, $entity_settings) {
   $bundle_settings = is_array($bundle_settings) ? $bundle_settings : (array) reply_bundle_load($bundle_settings);

-  foreach ($entity_settings AS $field => $value) {
+  foreach ($entity_settings as $field => $value) {
     if ($value == REPLY_INHERIT) {
       if ($instance_settings[$field] == REPLY_INHERIT) {
         if ($field_settings[$field] == REPLY_INHERIT) {
           $entity_settings[$field] = $bundle_settings[$field];
-        } else {
+        }
+        else {
           $entity_settings[$field] = $field_settings[$field];
         }
-      } else {
+      }
+      else {
         $entity_settings[$field] = $instance_settings[$field];
       }
     }
@@ -1930,57 +1934,57 @@ function reply_views_api() {
 }

 function theme_reply_post_forbidden($variables) {
-    $entity = $variables['entity'];
-    $entity_type = $variables['entity_type'];
-    $entity_info = entity_extract_ids($entity_type, $entity);
-    $entity_id = $entity_info[0];
-    $form = $variables['form'];
-    $instance_id = $variables['instance_id'];
-    $bundle = $variables['bundle'];
-    global $user;
-
-    $authenticated_post_reply = &drupal_static(__FUNCTION__, NULL);
-
-    if (!$user->uid) {
-        if (!isset($authenticated_post_reply)) {
-            // We only output a link if we are certain that users will get permission
-            // to post replies by logging in.
-
-            $reply_roles = user_roles(TRUE, 'post '. $bundle .' reply');
-            $authenticated_post_reply = isset($reply_roles[DRUPAL_AUTHENTICATED_RID]);
-        }
+  $entity = $variables['entity'];
+  $entity_type = $variables['entity_type'];
+  $entity_info = entity_extract_ids($entity_type, $entity);
+  $entity_id = $entity_info[0];
+  $form = $variables['form'];
+  $instance_id = $variables['instance_id'];
+  $bundle = $variables['bundle'];
+  global $user;
+
+  $authenticated_post_reply = &drupal_static(__FUNCTION__, NULL);
+
+  if (!$user->uid) {
+    if (!isset($authenticated_post_reply)) {
+      // We only output a link if we are certain that users will get permission
+      // to post replies by logging in.
+
+      $reply_roles = user_roles(TRUE, 'post ' . $bundle . ' reply');
+      $authenticated_post_reply = isset($reply_roles[DRUPAL_AUTHENTICATED_RID]);
+    }

-        if ($authenticated_post_reply) {
-            // We cannot use drupal_get_destination() because these links
-            // sometimes appear on /node and taxonomy listing pages.
-            if ($form == REPLY_FORM_PAGE_CUSTOM) {
-                $destination = array('destination' =>  'reply/add/' . $entity_id . '/' . $instance_id . '/0');
-            }
-            else {
-                $entity_uri = entity_uri($entity_type, $entity);
-                $entity_uri = $entity_uri['path'];
-                $destination = array('destination' => "$entity_uri#reply-add-form");
-            }
+    if ($authenticated_post_reply) {
+      // We cannot use drupal_get_destination() because these links
+      // sometimes appear on /node and taxonomy listing pages.
+      if ($form == REPLY_FORM_PAGE_CUSTOM) {
+        $destination = array('destination' =>  'reply/add/' . $entity_id . '/' . $instance_id . '/0');
+      }
+      else {
+        $entity_uri = entity_uri($entity_type, $entity);
+        $entity_uri = $entity_uri['path'];
+        $destination = array('destination' => "$entity_uri#reply-add-form");
+      }

-            if (variable_get('user_register', USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL)) {
-                // Users can register themselves.
-                return t('<a href="@login">Log in</a> or <a href="@register">register</a> to post a reply', array('@login' => _reply_get_login_url($destination), '@register' => _reply_get_register_url($destination)));
-            }
-            else {
-                // Only admins can add new users, no public registration.
-                return t('<a href="@login">Log in</a> to post a reply', array('@login' => _reply_get_login_url($destination)));
-            }
+      if (variable_get('user_register', USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL)) {
+        // Users can register themselves.
+        return t('<a href="@login">Log in</a> or <a href="@register">register</a> to post a reply', array('@login' => _reply_get_login_url($destination), '@register' => _reply_get_register_url($destination)));
+      }
+      else {
+        // Only admins can add new users, no public registration.
+        return t('<a href="@login">Log in</a> to post a reply', array('@login' => _reply_get_login_url($destination)));
+      }

-        }
     }
+  }
 }

-function _reply_get_login_url($destination){
-    return url('user/login', array('query' => $destination));
+function _reply_get_login_url($destination) {
+  return url('user/login', array('query' => $destination));
 }

-function _reply_get_register_url($destination){
-    return url('user/register', array('query' => $destination));
+function _reply_get_register_url($destination) {
+  return url('user/register', array('query' => $destination));
 }

 function _ajax_add_reply($form_id, $entity_id, $instance_id, $parent=0, $ajax) {
@@ -2045,6 +2049,7 @@ function reply_add_form_submit_ajax($form, &$form_state) {
   if (form_get_errors()) {
     return '<div id="rformwrap">' . drupal_render($form) . '</div>';
   }
+  // @todo message?
   drupal_set_message($message);
   ctools_include('ajax');
   ctools_add_js('ajax-responder');
@@ -2061,6 +2066,7 @@ function reply_edit_form_submit_ajax($form, &$form_state) {
   if (form_get_errors()) {
     return '<div id="rformwrap">' . drupal_render($form) . '</div>';
   }
+  // @todo message?
   drupal_set_message($message);
   ctools_include('ajax');
   ctools_add_js('ajax-responder');
diff --git a/reply.tpl.php b/reply.tpl.php
index ee97266..992bfd3 100644
--- a/reply.tpl.php
+++ b/reply.tpl.php
@@ -1,4 +1,4 @@
 <div id="reply-<?php print $reply->id ?>" class="<?php print $classes ?>">
   <div class="reply-body"><?php print render($content) ?></div>
   <div class="reply-links"><?php print render($links) ?></div>
-</div>
\ No newline at end of file
+</div>
diff --git a/views/handlers/views_handler_field_reply_link_reply.inc b/views/handlers/views_handler_field_reply_link_reply.inc
index 813aab1..eb9bc56 100644
--- a/views/handlers/views_handler_field_reply_link_reply.inc
+++ b/views/handlers/views_handler_field_reply_link_reply.inc
@@ -5,7 +5,7 @@
  * @ingroup views_field_handlers
  */
 class views_handler_field_reply_link_reply extends views_handler_field_reply_link {
-
+
   /**
    * Renders the link.
    */
@@ -16,7 +16,7 @@ class views_handler_field_reply_link_reply extends views_handler_field_reply_lin
     }

     $this->options['alter']['make_link'] = TRUE;
-    $this->options['alter']['path'] = 'reply/add/'. $reply->entity_id .'/'. $reply->instance_id .'/'. $reply->id;
+    $this->options['alter']['path'] = 'reply/add/' . $reply->entity_id . '/' . $reply->instance_id . '/' . $reply->id;
     $this->options['alter']['query'] = drupal_get_destination();

     $text = !empty($this->options['text']) ? $this->options['text'] : t('Reply');
diff --git a/views/reply.views.inc b/views/reply.views.inc
index e42e908..8e95f88 100644
--- a/views/reply.views.inc
+++ b/views/reply.views.inc
@@ -55,18 +55,18 @@ function reply_views_data_alter(&$data) {
   // Add reply relationship to all entities with reply fields attached.
   $field_map = field_info_field_map();
   foreach ($field_map as $field_info) {
-    if($field_info['type'] == 'reply') {
+    if ($field_info['type'] == 'reply') {
       $entity_types = array_keys($field_info['bundles']);
       foreach ($entity_types as $entity_type) {
         $entity_info = entity_get_info($entity_type);
-        $data[$entity_type][$entity_info['entity keys']['id']]['relationship'] = array (
+        $data[$entity_type][$entity_info['entity keys']['id']]['relationship'] = array(
           'base' => 'reply',
           'base field' =>  'entity_id',
           'handler' => 'views_handler_relationship',
           'label' => t('Reply'),
           'title' => t('Reply'),
           'help' => t('Replies related to entity.'),
-          'extra' => array(array('field' => 'entity_type','value' => $entity_type)),
+          'extra' => array(array('field' => 'entity_type', 'value' => $entity_type)),
         );
       }
     }
