diff --git a/flag.api.php b/flag.api.php
index a37805d..f9e577a 100644
--- a/flag.api.php
+++ b/flag.api.php
@@ -16,17 +16,17 @@
  * This hook may be placed in a $module.flag.inc file.
  *
  * @return
- *  An array whose keys are flag type names and whose values are properties of
- *  the flag type.
- *  When a flag type is for an entity, the flag type name must match the entity
- *  type.
- *  Properties for flag types are as follows:
- *  - 'title': The main label of the flag type.
- *  - 'description': A longer description shown in the UI when creating a new
- *    flag.
- *  - 'handler': The name of the class implementing this flag type.
- *  - 'module': (optional) The name of the module that should be registered as a
- *    dependency for this flag type.
+ *   An array whose keys are flag type names and whose values are properties of
+ *   the flag type.
+ *   When a flag type is for an entity, the flag type name must match the entity
+ *   type.
+ *   Properties for flag types are as follows:
+ *   - 'title': The main label of the flag type.
+ *   - 'description': A longer description shown in the UI when creating a new
+ *     flag.
+ *   - 'handler': The name of the class implementing this flag type.
+ *   - 'module': (optional) The name of the module that should be registered as
+ *     a dependency for this flag type.
  *
  * @see flag_fetch_definition()
  */
@@ -47,7 +47,7 @@ function hook_flag_type_info() {
  * This hook may be placed in a $module.flag.inc file.
  *
  * @param $definitions
- *  An array of flag definitions returned by hook_flag_type_info().
+ *   An array of flag definitions returned by hook_flag_type_info().
  */
 function hook_flag_type_info_alter(&$definitions) {
 
@@ -58,11 +58,11 @@ function hook_flag_type_info_alter(&$definitions) {
  */
 function hook_flag_default_flags() {
   $flags = array();
-  $flags['bookmarks'] = array (
+  $flags['bookmarks'] = array(
     'entity_type' => 'node',
     'title' => 'Bookmarks',
     'global' => FALSE,
-    'types' => array (
+    'types' => array(
       0 => 'article',
       1 => 'blog',
     ),
@@ -75,7 +75,7 @@ function hook_flag_default_flags() {
     'unflag_denied_text' => '',
     'link_type' => 'toggle',
     'weight' => 0,
-    'show_in_links' => array (
+    'show_in_links' => array(
       'full' => TRUE,
       'token' => FALSE,
     ),
@@ -93,7 +93,7 @@ function hook_flag_default_flags() {
 /**
  * Allow modules to alter a flag when it is initially loaded.
  *
- * @see flag_get_flags().
+ * @see flag_get_flags()
  */
 function hook_flag_alter(&$flag) {
 
@@ -107,10 +107,10 @@ function hook_flag_alter(&$flag) {
  * flag object.
  *
  * @param $options
- *  The array of default options for the flag type, with the options for the
- *  flag's link type merged in.
+ *   The array of default options for the flag type, with the options for the
+ *   flag's link type merged in.
  * @param $flag
- *  The flag object.
+ *   The flag object.
  *
  * @see flag_flag::options()
  */
@@ -122,13 +122,13 @@ function hook_flag_options_alter(&$options, $flag) {
  * Act on an object being flagged.
  *
  * @param $flag
- *  The flag object.
+ *   The flag object.
  * @param $entity_id
- *  The id of the entity the flag is on.
+ *   The id of the entity the flag is on.
  * @param $account
- *  The user account performing the action.
- * @param $flagging_id
- *  The flagging entity.
+ *   The user account performing the action.
+ * @param $flagging
+ *   The flagging entity.
  */
 function hook_flag_flag($flag, $entity_id, $account, $flagging) {
 
@@ -141,13 +141,13 @@ function hook_flag_flag($flag, $entity_id, $account, $flagging) {
  * flagging entity has been deleted.
  *
  * @param $flag
- *  The flag object.
+ *   The flag object.
  * @param $entity_id
- *  The id of the entity the flag is on.
+ *   The id of the entity the flag is on.
  * @param $account
- *  The user account performing the action.
+ *   The user account performing the action.
  * @param $flagging
- *  The flagging entity.
+ *   The flagging entity.
  */
 function hook_flag_unflag($flag, $entity_id, $account, $flagging) {
 
@@ -157,15 +157,15 @@ function hook_flag_unflag($flag, $entity_id, $account, $flagging) {
  * Perform custom validation on a flag before flagging/unflagging.
  *
  * @param $action
- *  The action about to be carried out. Either 'flag' or 'unflag'.
+ *   The action about to be carried out. Either 'flag' or 'unflag'.
  * @param $flag
- *  The flag object.
+ *   The flag object.
  * @param $entity_id
- *  The id of the entity the user is trying to flag or unflag.
+ *   The id of the entity the user is trying to flag or unflag.
  * @param $account
- *  The user account performing the action.
+ *   The user account performing the action.
  * @param $flagging
- *  The flagging entity.
+ *   The flagging entity.
  *
  * @return
  *   Optional array: textual error with the error-name as the key.
@@ -183,7 +183,7 @@ function hook_flag_validate($action, $flag, $entity_id, $account, $skip_permissi
       $count = count($flags[$flag->name]);
       if ($count >= 2) {
         // Users may flag only 2 nodes with this flag.
-        return(array('access-denied' => t('You may only flag 2 nodes with the test flag.')));
+        return (array('access-denied' => t('You may only flag 2 nodes with the test flag.')));
       }
     }
   }
@@ -196,13 +196,13 @@ function hook_flag_validate($action, $flag, $entity_id, $account, $skip_permissi
  * checks from within Views, implement hook_flag_access_multiple().
  *
  * @param $flag
- *  The flag object.
+ *   The flag object.
  * @param $entity_id
- *  The id of the entity in question.
+ *   The id of the entity in question.
  * @param $action
- *  The action to test. Either 'flag' or 'unflag'.
+ *   The action to test. Either 'flag' or 'unflag'.
  * @param $account
- *  The user on whose behalf to test the flagging action.
+ *   The user on whose behalf to test the flagging action.
  *
  * @return
  *   One of the following values:
@@ -227,11 +227,11 @@ function hook_flag_access($flag, $entity_id, $action, $account) {
  * For flag access checks for individual entities, see hook_flag_access().
  *
  * @param $flag
- *  The flag object.
+ *   The flag object.
  * @param $entity_ids
- *  An array of object ids to check access.
+ *   An array of object ids to check access.
  * @param $account
- *  The user on whose behalf to test the flagging action.
+ *   The user on whose behalf to test the flagging action.
  *
  * @return
  *   An array whose keys are the object IDs and values are booleans indicating
@@ -252,20 +252,20 @@ function hook_flag_access_multiple($flag, $entity_ids, $account) {
  * This hook may be placed in a $module.flag.inc file.
  *
  * @return
- *  An array of one or more types, keyed by the machine name of the type, and
- *  where each value is a link type definition as an array with the following
- *  properties:
- *  - 'title': The human-readable name of the type.
- *  - 'description': The description of the link type.
- *  - 'options': An array of extra options for the link type.
- *  - 'uses standard js': Boolean, indicates whether the link requires Flag
- *    module's own JS file for links.
- *  - 'uses standard css': Boolean, indicates whether the link requires Flag
- *    module's own CSS file for links.
- *  - 'provides form': (optional) Boolean indicating that this link type shows
- *    the user a flagging entity form. This property is used in the UI, eg to
- *    warn the admin user of link types that are not compatible with other
- *    flag options. Defaults to FALSE.
+ *   An array of one or more types, keyed by the machine name of the type, and
+ *   where each value is a link type definition as an array with the following
+ *   properties:
+ *   - 'title': The human-readable name of the type.
+ *   - 'description': The description of the link type.
+ *   - 'options': An array of extra options for the link type.
+ *   - 'uses standard js': Boolean, indicates whether the link requires Flag
+ *     module's own JS file for links.
+ *   - 'uses standard css': Boolean, indicates whether the link requires Flag
+ *     module's own CSS file for links.
+ *   - 'provides form': (optional) Boolean indicating that this link type shows
+ *     the user a flagging entity form. This property is used in the UI, eg to
+ *     warn the admin user of link types that are not compatible with other
+ *     flag options. Defaults to FALSE.
  *
  * @see flag_get_link_types()
  * @see hook_flag_link_type_info_alter()
@@ -280,7 +280,7 @@ function hook_flag_link_type_info() {
  * This hook may be placed in a $module.flag.inc file.
  *
  * @param $link_types
- *  An array of the link types defined by all modules.
+ *   An array of the link types defined by all modules.
  *
  * @see flag_get_link_types()
  * @see hook_flag_link_type_info()
@@ -324,7 +324,7 @@ function hook_flag_link() {
  * entries deleted.
  *
  * @param $flag
- *  The flag object that has been deleted.
+ *   The flag object that has been deleted.
  */
 function hook_flag_delete($flag) {
 
@@ -334,12 +334,12 @@ function hook_flag_delete($flag) {
  * Act when a flag is reset.
  *
  * @param $flag
- *  The flag object.
+ *   The flag object.
  * @param $entity_id
- *  The entity ID on which all flaggings are to be removed. May be NULL, in
+ *   The entity ID on which all flaggings are to be removed. May be NULL, in
  *  which case all of this flag's entities are to be unflagged.
  * @param $rows
- *  Database rows from the {flagging} table.
+ *   Database rows from the {flagging} table.
  *
  * @see flag_reset_flag()
  */
@@ -373,7 +373,7 @@ function hook_flag_javascript_info_alter(&$info, $flag) {
  * Alter a flag object that is being prepared for exporting.
  *
  * @param $flag
- *  The flag object.
+ *   The flag object.
  *
  * @see flag_export_flags()
  */
diff --git a/flag.info.inc b/flag.info.inc
index 69bbb5c..890e624 100644
--- a/flag.info.inc
+++ b/flag.info.inc
@@ -1,7 +1,8 @@
 <?php
 
 /**
- * @file Contains Entity API property information.
+ * @file
+ * Contains Entity API property information.
  */
 
 /**
diff --git a/flag.install b/flag.install
index 1932e4d..5e2063a 100644
--- a/flag.install
+++ b/flag.install
@@ -113,7 +113,7 @@ function flag_schema() {
         'not null' => TRUE,
         'default' => 0,
         'disp-size' => 11,
-      )
+      ),
     ),
     'primary key' => array('flagging_id'),
     'unique keys' => array(
@@ -121,7 +121,12 @@ function flag_schema() {
     ),
     'indexes' => array(
       'entity_type_uid_sid' => array('entity_type', 'uid', 'sid'),
-      'entity_type_entity_id_uid_sid' => array('entity_type', 'entity_id', 'uid', 'sid'),
+      'entity_type_entity_id_uid_sid' => array(
+        'entity_type',
+        'entity_id',
+        'uid',
+        'sid',
+      ),
       'entity_id_fid' => array('entity_id', 'fid'),
     ),
   );
@@ -190,7 +195,7 @@ function flag_schema() {
         'not null' => TRUE,
         'default' => 0,
         'disp-size' => 11,
-      )
+      ),
     ),
     'primary key' => array('fid', 'entity_id'),
     'indexes' => array(
@@ -296,7 +301,11 @@ function flag_update_6200() {
 function flag_update_6201() {
   // Remove "content type" from one key, see http://drupal.org/node/612602.
   db_drop_unique_key('flag_content', 'fid_content_type_content_id_uid');
-  db_add_unique_key('flag_content', 'fid_content_id_uid', array('fid', 'content_id', 'uid'));
+  db_add_unique_key('flag_content', 'fid_content_id_uid', array(
+    'fid',
+    'content_id',
+    'uid',
+  ));
 
   // Add a count index, see http://drupal.org/node/489610.
   db_add_index('flag_counts', 'count', array('count'));
@@ -311,11 +320,25 @@ function flag_update_6202() {
   db_drop_index('flag_content', 'content_type_uid');
 
   // Add the column.
-  db_add_field('flag_content', 'sid', array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0));
+  db_add_field('flag_content', 'sid', array(
+    'type' => 'int',
+    'unsigned' => TRUE,
+    'not null' => TRUE,
+    'default' => 0,
+  ));
 
   // Re-add the removed keys.
-  db_add_unique_key('flag_content', 'fid_content_id_uid_sid', array('fid', 'content_id', 'uid', 'sid'));
-  db_add_index('flag_content', 'content_type_uid_sid', array('content_type', 'uid', 'sid'));
+  db_add_unique_key('flag_content', 'fid_content_id_uid_sid', array(
+    'fid',
+    'content_id',
+    'uid',
+    'sid',
+  ));
+  db_add_index('flag_content', 'content_type_uid_sid', array(
+    'content_type',
+    'uid',
+    'sid',
+  ));
 }
 
 /**
@@ -357,14 +380,25 @@ function flag_update_6206() {
     db_drop_unique_key('flag_content', 'content_type_content_id_uid_sid');
   }
 
-  db_add_index('flag_content', 'content_type_content_id_uid_sid', array('content_type', 'content_id', 'uid', 'sid'));
+  db_add_index('flag_content', 'content_type_content_id_uid_sid', array(
+    'content_type',
+    'content_id',
+    'uid',
+    'sid',
+  ));
 }
 
 /**
  * Adds column last_updated to flag_counts table.
  */
 function flag_update_6207() {
-  db_add_field('flag_counts', 'last_updated', array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, 'disp-size' => 11), array('indexes' => array('last_updated' => array('last_updated'))));
+  db_add_field('flag_counts', 'last_updated', array(
+    'type' => 'int',
+    'unsigned' => TRUE,
+    'not null' => TRUE,
+    'default' => 0,
+    'disp-size' => 11),
+    array('indexes' => array('last_updated' => array('last_updated'))));
 }
 
 /**
@@ -482,7 +516,12 @@ function flag_update_7303() {
       ),
       'indexes' => array(
         'entity_type_uid_sid' => array('entity_type', 'uid', 'sid'),
-        'entity_type_content_id_uid_sid' => array('entity_type', 'content_id', 'uid', 'sid'),
+        'entity_type_content_id_uid_sid' => array(
+          'entity_type',
+          'content_id',
+          'uid',
+          'sid',
+        ),
         'content_id_fid' => array('content_id', 'fid'),
       ),
     )
@@ -510,7 +549,12 @@ function flag_update_7303() {
         'fid_entity_id_uid_sid' => array('fid', 'entity_id', 'uid', 'sid'),
       ),
       'indexes' => array(
-        'entity_type_entity_id_uid_sid' => array('entity_type', 'entity_id', 'uid', 'sid'),
+        'entity_type_entity_id_uid_sid' => array(
+          'entity_type',
+          'entity_id',
+          'uid',
+          'sid',
+        ),
         'entity_id_fid' => array('entity_id', 'fid'),
       ),
     )
@@ -569,7 +613,7 @@ function flag_update_7304() {
       'indexes' => array(
         'fid_entity_type' => array('fid', 'entity_type'),
         'entity_type_content_id' => array('entity_type', 'content_id'),
-      )
+      ),
     )
   );
 
@@ -671,7 +715,8 @@ function flag_update_7306() {
     }
 
     // Update show_on_comment and show_on_entity properties to use new view
-    // mode settings. Since the old logic was to show on all view modes, do that.
+    // mode settings. Since the old logic was to show on all view modes, do
+    // that.
     if (!empty($flag->show_on_entity) || !empty($flag->show_on_comment)) {
       if ($entity_info = entity_get_info($flag->entity_type)) {
         foreach ($entity_info['view modes'] as $view_mode => $value) {
diff --git a/flag.module b/flag.module
index ca06c2c..c9e8c39 100644
--- a/flag.module
+++ b/flag.module
@@ -160,14 +160,15 @@ function flagging_save($flagging) {
 // @todo: flag_reset_flag():
 // - it should delete the flaggings.
 // - (it has other issues; see http://drupal.org/node/894992.)
-// - (is problematic: it might not be possible to delete all data in a single page request.)
+// - (is problematic: it might not be possible to delete all data in a single
+//   page request.)
 
 // @todo: Discuss: Note that almost all functions/identifiers dealing with
 // flaggings *aren't* prefixed by "flag_". For example:
-//  - The menu argument is %flagging, not %flag_flagging.
-//  - The entity type is "flagging", not "flag_flagging".
-// On the one hand this succinct version is readable and nice. On the other hand, it isn't
-// very "correct".
+// - The menu argument is %flagging, not %flag_flagging.
+// - The entity type is "flagging", not "flag_flagging".
+// On the one hand this succinct version is readable and nice. On the other
+// hand, it isn't very "correct".
 
 /**
  * Implements hook_entity_query_alter().
@@ -182,7 +183,8 @@ function flag_entity_query_alter(EntityFieldQuery $query) {
 
   // Alter only flagging queries with bundle conditions.
   if (isset($conditions['entity_type']) && $conditions['entity_type']['value'] == 'flagging' && isset($conditions['bundle'])) {
-    $query->addTag('flagging_flag_names'); // Add tag to alter query.
+    // Add tag to alter query.
+    $query->addTag('flagging_flag_names');
     // Make value and operator of the bundle condition accessible
     // in hook_query_TAG_alter.
     $query->addMetaData('flag_name_value', $conditions['bundle']['value']);
@@ -253,7 +255,8 @@ function flag_menu() {
   );
 
   $items[FLAG_ADMIN_PATH . '/manage/%flag'] = array(
-    'load arguments' => array(TRUE), // Allow for disabled flags.
+    // Allow for disabled flags.
+    'load arguments' => array(TRUE),
     'page callback' => 'drupal_get_form',
     'page arguments' => array('flag_form', FLAG_ADMIN_PATH_START + 1),
     'access callback' => 'user_access',
@@ -265,7 +268,8 @@ function flag_menu() {
     'title arguments' => array(FLAG_ADMIN_PATH_START + 1),
   );
   $items[FLAG_ADMIN_PATH . '/manage/%flag/edit'] = array(
-    'load arguments' => array(TRUE), // Allow for disabled flags.
+    // Allow for disabled flags.
+    'load arguments' => array(TRUE),
     'title' => 'Edit flag',
     'type' => MENU_DEFAULT_LOCAL_TASK,
     'weight' => -10,
@@ -289,7 +293,8 @@ function flag_menu() {
     'type' => MENU_CALLBACK,
   );
   $items[FLAG_ADMIN_PATH . '/manage/%flag/update'] = array(
-    'load arguments' => array(TRUE), // Allow for disabled flags.
+    // Allow for disabled flags.
+    'load arguments' => array(TRUE),
     'title' => 'Update',
     'page callback' => 'flag_update_page',
     'page arguments' => array(FLAG_ADMIN_PATH_START + 1),
@@ -371,6 +376,7 @@ function flag_admin_menu_map() {
  *
  * @param $flag_name
  *   The machine name of the flag.
+ *
  * @param $include_disabled
  *   (optional) Whether to return a disabled flag too. Normally only enabled
  *   flags are returned. Some menu items operate on disabled flags and in this
@@ -416,9 +422,11 @@ function flag_help($path, $arg) {
     case FLAG_ADMIN_PATH:
       $output = '<p>' . t('This page lists all the <em>flags</em> that are currently defined on this system.') . '</p>';
       return $output;
+
     case FLAG_ADMIN_PATH . '/add':
       $output = '<p>' . t('Select the type of flag to create. An individual flag can only affect one type of object. This cannot be changed once the flag is created.') . '</p>';
       return $output;
+
     case FLAG_ADMIN_PATH . '/manage/%/fields':
       // Get the existing link types that provide a flagging form.
       $link_types = flag_get_link_types();
@@ -562,20 +570,20 @@ function flag_get_types() {
  * populates this empty flag with settings loaded from the database.
  *
  * @param $entity_type
- *  The entity type to create a flag handler for. This may be FALSE if the
- *  entity type property could not be found in the flag configuration data.
+ *   The entity type to create a flag handler for. This may be FALSE if the
+ *   entity type property could not be found in the flag configuration data.
  *
  * @return
- *  A flag handler object. This may be the special class flag_broken is there is
- *  a problem with the flag.
+ *   A flag handler object. This may be the special class flag_broken is there
+ *   is a problem with the flag.
  */
 function flag_create_handler($entity_type) {
   $definition = flag_fetch_definition($entity_type);
   if (isset($definition) && class_exists($definition['handler'])) {
-    $handler = new $definition['handler'];
+    $handler = new $definition['handler']();
   }
   else {
-    $handler = new flag_broken;
+    $handler = new flag_broken();
   }
   $handler->entity_type = $entity_type;
   $handler->construct();
@@ -662,7 +670,7 @@ function flag_field_extra_fields() {
         $extra[$flag->entity_type][$bundle_name]['form']['flag'] = array(
           'label' => t('Flags'),
           'description' => t('Checkboxes for toggling flags'),
-          'weight' => 10
+          'weight' => 10,
         );
       }
 
@@ -730,7 +738,7 @@ function flag_form_node_type_form_alter(&$form, &$form_state, $form_id) {
  * Warning: will not work on entity types that are not fieldable, as this relies
  * on a field module hook.
  *
- * @see flag_field_attach_submit().
+ * @see flag_field_attach_submit()
  */
 function flag_field_attach_form($entity_type, $entity, &$form, &$form_state, $langcode) {
   list($id) = entity_extract_ids($entity_type, $entity);
@@ -839,7 +847,7 @@ function flag_field_attach_form($entity_type, $entity, &$form, &$form_state, $la
 /**
  * Implements hook_field_attach_submit().
  *
- * @see flag_field_attach_form().
+ * @see flag_field_attach_form()
  */
 function flag_field_attach_submit($entity_type, $entity, $form, &$form_state) {
   // This is invoked for each flag_field_attach_form(), but possibly more than
@@ -877,7 +885,7 @@ function flag_field_attach_update($entity_type, $entity) {
 /**
  * Shared saving routine between flag_field_attach_insert/update().
  *
- * @see flag_field_attach_form().
+ * @see flag_field_attach_form()
  */
 function flag_field_attach_save($entity_type, $entity) {
   list($id) = entity_extract_ids($entity_type, $entity);
@@ -918,13 +926,14 @@ function flag_contextual_links_view_alter(&$element, $items) {
 
       list($entity_id) = entity_extract_ids($entity_type, $entity);
       if (!$flag->access($entity_id) && (!$flag->is_flagged($entity_id) || !$flag->access($entity_id, 'flag'))) {
-        // User has no permission to use this flag or flag does not apply to this
-        // object. The link is not skipped if the user has "flag" access but
-        // not "unflag" access (this way the unflag denied message is shown).
+        // User has no permission to use this flag or flag does not apply to
+        // this object. The link is not skipped if the user has "flag" access
+        // but not "unflag" access (this way the unflag denied message is
+        // shown).
         continue;
       }
 
-      $element['#links']['flag-'. $name] = array(
+      $element['#links']['flag-' . $name] = array(
         'title' => $flag->theme($flag->is_flagged($entity_id) ? 'unflag' : 'flag', $entity_id),
         'html' => TRUE,
       );
@@ -981,7 +990,7 @@ function flag_entity_view($entity, $type, $view_mode, $langcode) {
     // The pseudofield output.
     if ($flag->show_as_field) {
       $entity->content['flag_' . $flag->name] = array(
-       '#markup' => $flag->theme($flag->is_flagged($entity_id) ? 'unflag' : 'flag', $entity_id, array('needs_wrapping_element' => TRUE)),
+        '#markup' => $flag->theme($flag->is_flagged($entity_id) ? 'unflag' : 'flag', $entity_id, array('needs_wrapping_element' => TRUE)),
       );
     }
   }
@@ -1337,16 +1346,16 @@ function flag_flag_unflag($flag, $entity_id, $account, $flagging) {
 /**
  * Trigger actions if any are available. Helper for hook_flag_(un)flag().
  *
- * @param $op
- *  The operation being performed: one of 'flag' or 'unflag'.
+ * @param $action
+ *   The operation being performed: one of 'flag' or 'unflag'.
  * @param $flag
- *  The flag object.
+ *   The flag object.
  * @param $entity_id
- *  The id of the entity the flag is on.
+ *   The id of the entity the flag is on.
  * @param $account
- *  The user account performing the action.
- * @param $flagging_id
- *  The flagging entity.
+ *   The user account performing the action.
+ * @param $flagging
+ *   The flagging entity.
  */
 function flag_flag_trigger($action, $flag, $entity_id, $account, $flagging) {
   $context['hook'] = 'flag';
@@ -1359,8 +1368,9 @@ function flag_flag_trigger($action, $flag, $entity_id, $account, $flagging) {
   $object = $flag->fetch_entity($entity_id);
 
   // Generic "all flags" actions.
-  foreach (trigger_get_assigned_actions('flag_' . $action)  as $aid => $action_info) {
-    // The 'if ($aid)' is a safeguard against http://drupal.org/node/271460#comment-886564
+  foreach (trigger_get_assigned_actions('flag_' . $action) as $aid => $action_info) {
+    // The 'if ($aid)' is a safeguard against
+    // http://drupal.org/node/271460#comment-886564
     if ($aid) {
       actions_do($aid, $object, $context);
     }
@@ -1555,11 +1565,11 @@ function template_preprocess_flag(&$variables) {
   global $user;
   $initialized = &drupal_static(__FUNCTION__, array());
 
-  // Some typing shotcuts:
+  // Some typing shotcuts.
   $flag =& $variables['flag'];
   $action = $variables['action'];
   $entity_id = $variables['entity_id'];
-  $errors = join('<br />', $variables['errors']);
+  $errors = implode('<br />', $variables['errors']);
   $flag_css_name = str_replace('_', '-', $flag->name);
 
   // Generate the link URL.
@@ -1629,7 +1639,8 @@ function template_preprocess_flag(&$variables) {
       $variables['message_classes_array'][] = 'flag-' . $variables['status'] . '-message';
       $variables['message_text'] = $flag->get_label($inverse_action . '_message', $entity_id);
       $variables['flag_classes_array'][] = $variables['status'];
-      // By default we make our JS code remove, after a few seconds, only success messages.
+      // By default we make our JS code remove, after a few seconds, only
+      // success messages.
       $variables['message_classes_array'][] = 'flag-auto-remove';
     }
   }
@@ -1642,8 +1653,8 @@ function template_preprocess_flag(&$variables) {
  * Theme processor for flag.tpl.php.
  *
  * @param array &$variables
- *  An array of variables for the template. See 'flag.tpl.php' for their
- *  documentation.
+ *   An array of variables for the template. See 'flag.tpl.php' for their
+ *   documentation.
  */
 function template_process_flag(&$variables) {
   // Convert class arrays to strings.
@@ -1689,7 +1700,7 @@ function _flag_link_type_descriptions() {
 }
 
 // ---------------------------------------------------------------------------
-// Non-Views public API
+// Non-Views public API.
 
 /**
  * Get the count of flags for a particular entity type.
@@ -1725,7 +1736,7 @@ function flag_get_entity_flag_counts($flag, $entity_type) {
       ->countQuery()
       ->execute()
       ->fetchField();
-    $counts[$flag->name][$entity_type] =  $result;
+    $counts[$flag->name][$entity_type] = $result;
   }
 
   return $counts[$flag->name][$entity_type];
@@ -1842,12 +1853,12 @@ function flag_get_flag_counts($flag_name, $reset = FALSE) {
  * Load a single flag either by name or by flag ID.
  *
  * @param $name
- *  (optional) The flag name.
+ *   (optional) The flag name.
  * @param $fid
- *  (optional) The the flag id.
+ *   (optional) The the flag id.
  *
  * @return
- *  The flag object, or FALSE if no matching flag was found.
+ *   The flag object, or FALSE if no matching flag was found.
  */
 function flag_get_flag($name = NULL, $fid = NULL) {
   $flags = flag_get_flags();
@@ -1894,7 +1905,14 @@ function flag_get_flags($entity_type = NULL, $content_subtype = NULL, $account =
     $query = db_select('flag', 'f');
     $query->leftJoin('flag_types', 'fn', 'fn.fid = f.fid');
     $result = $query
-      ->fields('f', array('fid', 'entity_type', 'name', 'title', 'global', 'options'))
+      ->fields('f', array(
+        'fid',
+        'entity_type',
+        'name',
+        'title',
+        'global',
+        'options',
+      ))
       ->fields('fn', array('type'))
       ->execute();
     foreach ($result as $row) {
@@ -1919,7 +1937,8 @@ function flag_get_flags($entity_type = NULL, $content_subtype = NULL, $account =
         // Ensure overridden flags are associated with their parent module.
         $flags[$name]->module = $default_flag->module;
 
-        // Update the flag with any properties that are "locked" by the code version.
+        // Update the flag with any properties that are "locked" by the code
+        // version.
         if (isset($default_flag->locked)) {
           $flags[$name]->locked = $default_flag->locked;
           foreach ($default_flag->locked as $property) {
@@ -2067,11 +2086,15 @@ function flag_get_flag_flagging_data($flag_name) {
  * @return
  *   If returning a single item's flags (that is, when $entity_id isn't NULL),
  *   an array of the structure
- *   [flag_name] => (flagging_id => [flagging_id], uid => [uid], entity_id => [entity_id], timestamp => [timestamp], ...)
+ *   [flag_name] => (
+ *     flagging_id => [flagging_id],
+ *     uid => [uid],
+ *     entity_id => [entity_id],
+ *     timestamp => [timestamp],
+ *     ...)
  *
  *   If returning all items' flags, an array of arrays for each flag:
  *   [flag_name] => [entity_id] => Object from above.
- *
  */
 function flag_get_user_flags($entity_type, $entity_id = NULL, $uid = NULL, $sid = NULL) {
   $flagged_content = &drupal_static(__FUNCTION__);
@@ -2199,11 +2222,11 @@ function flag_get_entity_flags($entity_type, $entity_id, $flag_name = NULL) {
  * @param $entity_id
  *   The entity ID to check for flagging, for example a node ID.
  * @param $variables
- *  An array of further variables to pass to theme('flag'). For the full list
- *  of parameters, see flag.tpl.php. Of particular interest:
- *  - after_flagging: Set to TRUE if this flag link is being displayed as the
- *    result of a flagging action.
- *  - errors: An array of error messages.
+ *   An array of further variables to pass to theme('flag'). For the full list
+ *   of parameters, see flag.tpl.php. Of particular interest:
+ *   - after_flagging: Set to TRUE if this flag link is being displayed as the
+ *     result of a flagging action.
+ *   - errors: An array of error messages.
  *
  * @return
  *   The HTML for the themed flag link.
@@ -2224,7 +2247,7 @@ function flag_create_link($flag_name, $entity_id, $variables = array()) {
 /**
  * Trim a flag to a certain size.
  *
- * @param $fid
+ * @param $flag
  *   The flag object.
  * @param $account
  *   The user object on behalf the trimming will occur.
@@ -2250,10 +2273,10 @@ function flag_trim_flag($flag, $account, $cutoff_size, $trim_newest, $permission
     $query->orderBy('timestamp', 'ASC');
   }
   else {
-    $query->orderBy('timestamp', 'DESC') ;
+    $query->orderBy('timestamp', 'DESC');
   }
 
-  // Execute the query
+  // Execute the query.
   $result = $query->execute();
 
   $i = 1;
@@ -2289,7 +2312,7 @@ function flag_reset_flag($flag, $entity_id = NULL) {
   }
   module_invoke_all('flag_reset', $flag, $entity_id, $rows);
 
-  $query = db_delete('flagging')->condition('fid' , $flag->fid);
+  $query = db_delete('flagging')->condition('fid', $flag->fid);
   // Update the flag_counts table.
   $count_query = db_delete('flag_counts')->condition('fid', $flag->fid);
   if ($entity_id) {
@@ -2304,12 +2327,12 @@ function flag_reset_flag($flag, $entity_id = NULL) {
  * Return an array of link types provided by modules.
  *
  * @return
- *  An array of link types as defined by hook_flag_link_type_info(). These are
- *  keyed by the type name, and each value is an array of properties. In
- *  addition to those defined in hook_flag_link_type_info(), the following
- *  properties are set:
- *  - 'module': The providing module.
- *  - 'name': The machine name of the type.
+ *   An array of link types as defined by hook_flag_link_type_info(). These are
+ *   keyed by the type name, and each value is an array of properties. In
+ *   addition to those defined in hook_flag_link_type_info(), the following
+ *   properties are set:
+ *   - 'module': The providing module.
+ *   - 'name': The machine name of the type.
  *
  * @see hook_flag_link_type_info()
  * @see hook_flag_link_type_info_alter()
@@ -2589,25 +2612,27 @@ function flag_properties_get_flagging_users($entity, array $options, $name, $ent
  * Callback for hook_entity_property_info_alter().
  *
  * @param stdobj $entity
- *  The entity object representing a user for which we are getting inforamtion for.
+ *   The entity object representing a user for which we are getting inforamtion
+ *   for.
  *
  * @param array $options
- *  Options reguarding the nature of the entity. Language, etc.
+ *   Options reguarding the nature of the entity. Language, etc.
  *
  * @param string $name
- *  The name of the property we are running this callback for.
+ *   The name of the property we are running this callback for.
  *
  * @param string $entity_type
- *  The type that the stdobj $entity is supposed to be.
+ *   The type that the stdobj $entity is supposed to be.
  *
  * @param $property_info
- *  The ifnromatin that represents the property we are providing a result for.
+ *   The ifnromatin that represents the property we are providing a result for.
  *
- * @return an integer representing the user's sid field from the session_api table
+ * @return
+ *   An integer representing the user's sid field from the session_api table.
  *
  * @ingroup callbacks
  */
 function flag_properties_get_user_sid($entity, array $options, $name, $entity_type, $property_info) {
-  $sid =  flag_get_sid($entity->uid, FALSE);
+  $sid = flag_get_sid($entity->uid, FALSE);
   return $sid;
 }
diff --git a/flag.rules.inc b/flag.rules.inc
index d3d047e..9e3b01c 100644
--- a/flag.rules.inc
+++ b/flag.rules.inc
@@ -81,7 +81,7 @@ class FlagRulesUIClass extends RulesDataUI implements RulesDataDirectInputFormIn
       '#required' => empty($info['optional']),
       '#multiple' => FALSE,
       '#default_value' => $settings[$name],
-      '#empty' => t('There is no suiting flag available.')
+      '#empty' => t('There is no suiting flag available.'),
     );
     return $form;
   }
@@ -375,9 +375,10 @@ function flag_rules_action_info() {
       'access callback' => 'flag_rules_integration_access',
     );
   }
-  // For backward compatibility sake. This was the original name of the 'fetch node by user'.
+  // For backward compatibility sake. This was the original name of the
+  // 'fetch node by user'.
   $items['flag_fetch_entity_by_user'] = $items['flag_fetch_node_by_user'];
-  $items['flag_fetch_entity_by_user']['label'] .= ' '. t('(Legacy)');
+  $items['flag_fetch_entity_by_user']['label'] .= ' ' . t('(Legacy)');
   return $items;
 }
 
@@ -461,8 +462,8 @@ function flag_rules_action_fetch_overall_flag_count($flag) {
 /**
  * Helper function which will return all the available flag types.
  *
- *  @return
- *  An array of flag type names keyed by the type name.
+ * @return
+ *   An array of flag type names keyed by the type name.
  */
 function flag_rules_get_flag_types() {
   $types = array();
@@ -473,7 +474,8 @@ function flag_rules_get_flag_types() {
 }
 
 /**
- * Base action implementation: Fetch count of flags for a particular entity type.
+ * Base action implementation: Fetch count of flags for a particular entity
+ * type.
  *
  * During a flagging, the current flagging will be included in the count.
  * During an unflagging, the current flagging being removed will not yet have
@@ -513,7 +515,7 @@ function flag_rules_condition_info() {
             'type' => 'flag',
             'label' => t('Flag'),
             'flag_type' => $type,
-            'description' => t('The flag to check for.')
+            'description' => t('The flag to check for.'),
           ),
           $type => array(
             'type' => $type,
@@ -549,7 +551,7 @@ function flag_rules_condition_info() {
             'type' => 'flag',
             'label' => t('Flag'),
             'flag_type' => $type,
-            'description' => t('The flag to check for.')
+            'description' => t('The flag to check for.'),
           ),
           $type => array(
             'type' => $type,
@@ -570,7 +572,8 @@ function flag_rules_condition_info() {
 }
 
 /**
- * Options list callback for the operator parameter of the flagging threshold condition.
+ * Options list callback for the operator parameter of the flagging threshold
+ * condition.
  */
 function flag_rules_condition_threshold_operator_options() {
   return array(
@@ -592,10 +595,10 @@ function flag_rules_condition_threshold($flag, $entity, $number, $operator = '='
   $count = $flag->get_count($flag->get_entity_id($entity));
 
   switch ($operator) {
-    case '>' : return $count >  $number;
+    case '>': return $count > $number;
     case '>=': return $count >= $number;
-    case '=' : return $count == $number;
-    case '<' : return $count <  $number;
+    case '=': return $count == $number;
+    case '<': return $count < $number;
     case '<=': return $count <= $number;
   }
 }
diff --git a/flag.tokens.inc b/flag.tokens.inc
index cae4d88..77a06c5 100644
--- a/flag.tokens.inc
+++ b/flag.tokens.inc
@@ -123,6 +123,7 @@ function flag_tokens($type, $tokens, array $data = array(), array $options = arr
         case 'name':
           $replacements[$original] = $sanitize ? check_plain($flag->name) : $flag->name;
           break;
+
         case 'title':
           $replacements[$original] = $sanitize ? check_plain($flag->get_title()) : $flag->get_title();
           break;
@@ -149,18 +150,23 @@ function flag_tokens($type, $tokens, array $data = array(), array $options = arr
         case 'action':
           $replacements[$original] = $action->action;
           break;
+
         case 'entity-url':
           $replacements[$original] = $sanitize ? check_url($action->entity_url) : $action->entity_url;
           break;
+
         case 'entity-title':
           $replacements[$original] = $sanitize ? check_plain($action->entity_title) : $action->entity_title;
           break;
+
         case 'entity-type':
           $replacements[$original] = $action->entity_type;
           break;
+
         case 'entity-id':
           $replacements[$original] = $action->entity_id;
           break;
+
         case 'count':
           $replacements[$original] = $action->count;
           break;
diff --git a/flag_actions.module b/flag_actions.module
index f4c3aed..4870e61 100644
--- a/flag_actions.module
+++ b/flag_actions.module
@@ -379,7 +379,7 @@ function theme_flag_actions_add_form($variables) {
   $fieldset = array(
     '#type' => 'fieldset',
     '#title' => t('Add a new flag action'),
-    '#children' => '<div class="container-inline">'. drupal_render($form['flag']) . drupal_render($form['submit']) .'</div>',
+    '#children' => '<div class="container-inline">' . drupal_render($form['flag']) . drupal_render($form['submit']) . '</div>',
     '#parents' => array('add_action'),
     '#attributes' => array(),
     '#groups' => array('add_action' => array()),
@@ -397,7 +397,6 @@ function theme_flag_actions_add_form($variables) {
  *   If editing an action, an action ID must be passed in.
  * @param $flag_name
  *   If adding a new action to a flag, a flag name must be specified.
- *
  */
 function flag_actions_form($form, &$form_state, $aid = NULL, $flag_name = NULL) {
   // This is a multistep form. Get the callback value if set and continue.
@@ -422,7 +421,7 @@ function flag_actions_form($form, &$form_state, $aid = NULL, $flag_name = NULL)
 
   $form['new'] = array(
     '#type' => 'value',
-    '#value' => isset($callback) ? FALSE: TRUE,
+    '#value' => isset($callback) ? FALSE : TRUE,
   );
 
   if (!isset($callback)) {
@@ -430,7 +429,7 @@ function flag_actions_form($form, &$form_state, $aid = NULL, $flag_name = NULL)
 
     $actions = $flag->get_valid_actions();
     $options = array();
-    foreach($actions as $key => $action) {
+    foreach ($actions as $key => $action) {
       $options[$key] = $action['label'];
     }
 
@@ -449,7 +448,7 @@ function flag_actions_form($form, &$form_state, $aid = NULL, $flag_name = NULL)
   }
   elseif (!isset($action)) {
     $actions = $flag->get_valid_actions();
-    $action = (object)$actions[$callback];
+    $action = (object) $actions[$callback];
     $action->parameters = array();
     $action->event = 'flag';
     $action->threshold = 10;
@@ -512,7 +511,7 @@ function flag_actions_form($form, &$form_state, $aid = NULL, $flag_name = NULL)
   }
 
   // Merge in the standard flag action form.
-  $action_form = $callback .'_form';
+  $action_form = $callback . '_form';
   $edit = array();
   if (function_exists($action_form)) {
     $edit += $action->parameters;
@@ -524,7 +523,7 @@ function flag_actions_form($form, &$form_state, $aid = NULL, $flag_name = NULL)
   }
 
   // Add a few customizations to existing flag actions.
-  $flag_actions_form = 'flag_actions_'. $callback .'_form';
+  $flag_actions_form = 'flag_actions_' . $callback . '_form';
   if (function_exists($flag_actions_form)) {
     $flag_actions_form($form, $flag, $edit);
   }
diff --git a/flag_bookmark/flag_bookmark.install b/flag_bookmark/flag_bookmark.install
index 284784a..6264612 100644
--- a/flag_bookmark/flag_bookmark.install
+++ b/flag_bookmark/flag_bookmark.install
@@ -13,7 +13,7 @@
  */
 function flag_bookmark_enable() {
   // Load the flag API in case we want to use it when enabling.
-  include_once(drupal_get_path('module', 'flag') . '/flag.module');
+  include_once drupal_get_path('module', 'flag') . '/flag.module';
 
   if (!flag_get_flags()) {
     // Install a demonstration flag only if no flag exists. This is to prevent
@@ -21,24 +21,24 @@ function flag_bookmark_enable() {
     // flag is overwritten or re-created.
     $flag = flag_flag::factory_by_entity_type('node');
     $configuration = array(
-        'name' => 'bookmarks',
-        'global' => 0,
-        'show_in_links' => array(
-          'full' => 1,
-          'teaser' => 1,
-        ),
-        'show_on_form' => 1,
-        // The following UI labels aren't wrapped in t() because they are written
-        // to the DB in English. They are passed to t() later, thus allowing for
-        // multilingual sites.
-        'title' => 'Bookmarks',
-        'flag_short' => 'Bookmark this',
-        'flag_long' => 'Add this post to your bookmarks',
-        'flag_message' => 'This post has been added to your bookmarks',
-        'unflag_short' => 'Unbookmark this',
-        'unflag_long' => 'Remove this post from your bookmarks',
-        'unflag_message' => 'This post has been removed from your bookmarks',
-        'types' => _flag_bookmark_install_get_suggested_node_types(),
+      'name' => 'bookmarks',
+      'global' => 0,
+      'show_in_links' => array(
+        'full' => 1,
+        'teaser' => 1,
+      ),
+      'show_on_form' => 1,
+      // The following UI labels aren't wrapped in t() because they are written
+      // to the DB in English. They are passed to t() later, thus allowing for
+      // multilingual sites.
+      'title' => 'Bookmarks',
+      'flag_short' => 'Bookmark this',
+      'flag_long' => 'Add this post to your bookmarks',
+      'flag_message' => 'This post has been added to your bookmarks',
+      'unflag_short' => 'Unbookmark this',
+      'unflag_long' => 'Remove this post from your bookmarks',
+      'unflag_message' => 'This post has been removed from your bookmarks',
+      'types' => _flag_bookmark_install_get_suggested_node_types(),
     );
     $flag->form_input($configuration);
     $flag->save();
@@ -53,7 +53,8 @@ function flag_bookmark_enable() {
 }
 
 /**
- * Returns some node types to which the demonstration 'bookmarks' flag will apply.
+ * Returns some node types to which the demonstration 'bookmarks' flag will
+ * apply.
  */
 function _flag_bookmark_install_get_suggested_node_types() {
   $preferred = array('article', 'story', 'forum', 'blog');
@@ -64,4 +65,3 @@ function _flag_bookmark_install_get_suggested_node_types() {
   }
   return $existing;
 }
-
diff --git a/flag_bookmark/includes/flag_bookmark.views_default.inc b/flag_bookmark/includes/flag_bookmark.views_default.inc
index e656ca3..95c0a74 100644
--- a/flag_bookmark/includes/flag_bookmark.views_default.inc
+++ b/flag_bookmark/includes/flag_bookmark.views_default.inc
@@ -191,7 +191,7 @@ function flag_bookmark_views_default_views() {
     ),
   );
 
-  $view = new view;
+  $view = new view();
   $view->name = 'flag_bookmarks_tab';
   $view->description = "Provides a tab on all users' profile pages containing bookmarks for that user.";
   $view->tag = 'flag';
@@ -244,7 +244,7 @@ function flag_bookmark_views_default_views() {
     ),
   );
 
-  $view = new view;
+  $view = new view();
   $view->name = 'flag_' . $flag->name;
   $view->description = "A page listing the current user's bookmarks at /bookmarks.";
   $view->tag = 'flag';
diff --git a/includes/flag.actions.inc b/includes/flag.actions.inc
index f414431..c920971 100644
--- a/includes/flag.actions.inc
+++ b/includes/flag.actions.inc
@@ -15,7 +15,7 @@ function flag_trigger_info() {
         'label' => t('Object has been flagged with any flag'),
       ),
       'flag_unflag' => array(
-        'label' => t('Object has been unflagged with any flag')
+        'label' => t('Object has been unflagged with any flag'),
       ),
     ),
   );
diff --git a/includes/flag.admin.inc b/includes/flag.admin.inc
index 190ceb7..8cc9c45 100644
--- a/includes/flag.admin.inc
+++ b/includes/flag.admin.inc
@@ -77,10 +77,10 @@ function theme_flag_admin_listing($variables) {
 
   foreach ($flags as $flag) {
     $ops = array(
-      'flags_edit' =>  array('title' => t('edit'), 'href' => $flag->admin_path('edit')),
-      'flags_fields' =>  array('title' => t('manage fields'), 'href' => $flag->admin_path('fields')),
-      'flags_delete' =>  array('title' => t('delete'), 'href' => $flag->admin_path('delete')),
-      'flags_export' =>  array('title' => t('export'), 'href' => $flag->admin_path('export')),
+      'flags_edit' => array('title' => t('edit'), 'href' => $flag->admin_path('edit')),
+      'flags_fields' => array('title' => t('manage fields'), 'href' => $flag->admin_path('fields')),
+      'flags_delete' => array('title' => t('delete'), 'href' => $flag->admin_path('delete')),
+      'flags_export' => array('title' => t('export'), 'href' => $flag->admin_path('export')),
     );
     if (!module_exists('field_ui')) {
       unset($ops['flags_fields']);
@@ -116,7 +116,13 @@ function theme_flag_admin_listing($variables) {
   if (count($flags) > 1) {
     $header[] = t('Weight');
   }
-  $header = array_merge($header, array(t('Flag type'), t('Roles'), t('Entity bundles'), t('Global?'), t('Operations')));
+  $header = array_merge($header, array(
+    t('Flag type'),
+    t('Roles'),
+    t('Entity bundles'),
+    t('Global?'),
+    t('Operations'),
+  ));
   $output .= theme('table', array(
     'header' => $header,
     'rows' => $rows,
@@ -142,7 +148,11 @@ function theme_flag_admin_listing_disabled($variables) {
       $ops = array();
       if (!$flag->is_compatible()) {
         $flag_updates_needed = TRUE;
-        $ops['flags_update'] = array('title' => '<strong>' . t('update code') . '</strong>', 'href' => $flag->admin_path('update'), 'html' => TRUE);
+        $ops['flags_update'] = array(
+          'title' => '<strong>' . t('update code') . '</strong>',
+          'href' => $flag->admin_path('update'),
+          'html' => TRUE,
+        );
       }
       else {
         $ops['flags_enable'] = array('title' => t('enable'), 'href' => $flag->admin_path('edit'));
@@ -163,7 +173,12 @@ function theme_flag_admin_listing_disabled($variables) {
   }
 
   if (!empty($rows)) {
-    $header = array(t('Disabled Flags'), t('Module'), t('Flag type'), t('Operations'));
+    $header = array(
+      t('Disabled Flags'),
+      t('Module'),
+      t('Flag type'),
+      t('Operations'),
+    );
     $output .= theme('table', array('header' => $header, 'rows' => $rows));
   }
 
@@ -218,9 +233,9 @@ function theme_flag_admin_page($variables) {
  * Menu callback for adding a new flag.
  *
  * @param $entity_type
- *  The entity type for the new flag, taken from the path argument. If not
- *  present (i.e., '/add'), a form showing all possible flag types is shown.
- *  Otherwise, this shows a form for adding af flag the given type.
+ *   The entity type for the new flag, taken from the path argument. If not
+ *   present (i.e., '/add'), a form showing all possible flag types is shown.
+ *   Otherwise, this shows a form for adding af flag the given type.
  *
  * @see flag_add_form()
  * @see flag_form()
@@ -379,17 +394,17 @@ function flag_form($form, &$form_state, $flag) {
     '#title' => t('Token replacement'),
     '#type' => 'fieldset',
     '#description' =>
-      '<p>' . t('The above six texts may contain any of the tokens listed below. For example, <em>"Flag link text"</em> could be entered as:') . '</p>' .
-      theme('item_list', array(
-        'items' => array(
-          t('Add &lt;em&gt;[node:title]&lt;/em&gt; to your favorites'),
-          t('Add this [node:type] to your favorites'),
-          t('Vote for this proposal ([node:flag-vote-count] people have already done so)'),
-        ),
-        'attributes' => array('class' => 'token-examples'),
-      )) .
-      '<p>' . t('These tokens will be replaced with the appropriate fields from the node (or user, or comment).') . '</p>' .
-      theme('flag_tokens_browser', array('types' => $flag->get_labels_token_types())),
+    '<p>' . t('The above six texts may contain any of the tokens listed below. For example, <em>"Flag link text"</em> could be entered as:') . '</p>' .
+    theme('item_list', array(
+      'items' => array(
+        t('Add &lt;em&gt;[node:title]&lt;/em&gt; to your favorites'),
+        t('Add this [node:type] to your favorites'),
+        t('Vote for this proposal ([node:flag-vote-count] people have already done so)'),
+      ),
+      'attributes' => array('class' => 'token-examples'),
+    )) .
+    '<p>' . t('These tokens will be replaced with the appropriate fields from the node (or user, or comment).') . '</p>' .
+    theme('flag_tokens_browser', array('types' => $flag->get_labels_token_types())),
     '#collapsible' => TRUE,
     '#collapsed' => TRUE,
   );
@@ -782,12 +797,12 @@ function flag_check_link_types($element) {
  * Clears various caches when one or more flags are modified.
  *
  * @param $entity_types
- *  The entity types for the flags. May be a single value or an array.
+ *   The entity types for the flags. May be a single value or an array.
  * @param $is_insert_or_delete
- *  Whether the modified flag is being inserted (saved for the first time) or
- *  deleted. This results in a more vigorous clearing of caches. In
- *  particular, when no flags exist yet, no Field admin UI paths exist and these
- *  need to be created.
+ *   Whether the modified flag is being inserted (saved for the first time) or
+ *   deleted. This results in a more vigorous clearing of caches. In
+ *   particular, when no flags exist yet, no Field admin UI paths exist and
+ *   these need to be created.
  */
 function _flag_clear_cache($entity_types, $is_insert_or_delete = FALSE) {
   if (!is_array($entity_types)) {
diff --git a/includes/flag.cookie_storage.inc b/includes/flag.cookie_storage.inc
index 856f582..07a3dfe 100644
--- a/includes/flag.cookie_storage.inc
+++ b/includes/flag.cookie_storage.inc
@@ -2,7 +2,7 @@
 
 /**
  * @file
- *   Contains the FlagCookieStorage class.
+ * Contains the FlagCookieStorage class.
  */
 
 /**
diff --git a/includes/flag.export.inc b/includes/flag.export.inc
index 539899c..c39e4dd 100644
--- a/includes/flag.export.inc
+++ b/includes/flag.export.inc
@@ -15,7 +15,8 @@
  *   in hook_flag_default_flags().
  */
 function flag_export_flags($flags = array(), $module = '', $indent = '') {
-  module_load_include('inc', 'features', 'features.export'); // For features_var_export() (optional).
+  // For features_var_export() (optional).
+  module_load_include('inc', 'features', 'features.export');
   $output = $indent . '$flags = array();' . "\n";
   foreach ($flags as $item) {
     if (is_object($item)) {
@@ -236,7 +237,12 @@ function flag_update_page($flag) {
     drupal_goto(FLAG_ADMIN_PATH);
   }
 
-  drupal_set_message(t('The flag %name is currently using the Flag API version @version, which is not compatible with the current version of Flag. You can upgrade this flag by pasting the below code into <em>@module_flag_default_flags()</em> function in the @module.module file.', array('%name' => $flag->name, '@version' => $flag->api_version, '@module' => $flag->module)), 'warning');
+  drupal_set_message(t('The flag %name is currently using the Flag API version @version, which is not compatible with the current version of Flag. You can upgrade this flag by pasting the below code into <em>@module_flag_default_flags()</em> function in the @module.module file.', array(
+    '%name' => $flag->name,
+    '@version' => $flag->api_version,
+    '@module' => $flag->module,
+  )),
+    'warning');
 
   flag_update_export($flag);
 
@@ -269,7 +275,7 @@ function flag_update_export(&$flag) {
     if (substr($class, 0, 11) == 'FlagUpdate_') {
       // @todo: change this to work with the static class when we drop support
       // for PHP 5.2: see commit d5b517.
-      $update_handler = new $class;
+      $update_handler = new $class();
       // Cast to string, as decimals as array keys seem to be rounded down to
       // ints, WTF PHP?
       $version = (string) $update_handler->old_api_version;
@@ -364,7 +370,8 @@ class FlagUpdate_3 {
     }
 
     // Update show_on_comment and show_on_entity properties to use new view
-    // mode settings. Since the old logic was to show on all view modes, do that.
+    // mode settings. Since the old logic was to show on all view modes, do
+    // that.
     if (!empty($flag->show_on_entity) || !empty($flag->show_on_comment)) {
       if ($entity_info = entity_get_info($flag->entity_type)) {
         foreach ($entity_info['view modes'] as $view_mode => $value) {
diff --git a/includes/flag/flag_comment.inc b/includes/flag/flag_comment.inc
index 58b15fc..7056023 100644
--- a/includes/flag/flag_comment.inc
+++ b/includes/flag/flag_comment.inc
@@ -2,7 +2,7 @@
 
 /**
  * @file
- *   Contains the flag_comment class.
+ * Contains the flag_comment class.
  */
 
 /**
diff --git a/includes/flag/flag_entity.inc b/includes/flag/flag_entity.inc
index e1ded1f..7e95bcf 100644
--- a/includes/flag/flag_entity.inc
+++ b/includes/flag/flag_entity.inc
@@ -2,7 +2,7 @@
 
 /**
  * @file
- *   Contains the flag_entity class.
+ * Contains the flag_entity class.
  */
 
 /**
@@ -138,7 +138,7 @@ class flag_entity extends flag_flag {
    * Provides permissions for this flag.
    *
    * @return
-   *  An array of permissions for hook_permission().
+   *   An array of permissions for hook_permission().
    */
   function get_permissions() {
     // For entity flags, use the human label of the entity.
diff --git a/includes/flag/flag_flag.inc b/includes/flag/flag_flag.inc
index 44e7a7a..da566de 100644
--- a/includes/flag/flag_flag.inc
+++ b/includes/flag/flag_flag.inc
@@ -2,13 +2,14 @@
 
 /**
  * @file
- *  Contains the flag_flag class.
- *  Flag type classes use an object oriented style inspired by that
- *  of Views 2.
+ * Contains the flag_flag class.
+ * Flag type classes use an object oriented style inspired by that
+ * of Views 2.
  */
 
 /**
- * This abstract class represents a flag, or, in Views 2 terminology, "a handler".
+ * This abstract class represents a flag, or, in Views 2 terminology,
+ * "a handler".
  *
  * This is the base class for all flag implementations. Notable derived
  * classes are flag_node and flag_comment.
@@ -29,8 +30,8 @@
  * - flag_flag::factory_by_array(), creates a flag handler from a configuration
  *   array. This is used by flag_get_default_flags() and the flag import form.
  * - flag_flag::factory_by_entity_type(), creates an empty flag handler for the
- *   given entity type. This is used when a new or dummy flag handler is required
- *   and there is no configuration yet.
+ *   given entity type. This is used when a new or dummy flag handler is
+ *   required and there is no configuration yet.
  *
  * The factory methods in turn all call the low-level function
  * flag_create_handler(), which obtains the correct handler for the flag, or if
@@ -94,7 +95,8 @@ class flag_flag {
   );
 
   /**
-   * An associative array containing textual errors that may be created during validation.
+   * An associative array containing textual errors that may be created during
+   * validation.
    *
    * The array keys should reflect the type of error being set. At this time,
    * the only "special" behavior related to the array keys is that
@@ -103,7 +105,7 @@ class flag_flag {
    *
    * @var array
    */
-  var $errors = array();
+  public $errors = array();
 
   /**
    * Creates a flag from a database row. Returns it.
@@ -135,7 +137,8 @@ class flag_flag {
     }
 
     if (!empty($row->type)) {
-      // The loop loading from the database should further populate this property.
+      // The loop loading from the database should further populate this
+      // property.
       $flag->types[] = $row->type;
     }
 
@@ -189,7 +192,8 @@ class flag_flag {
       'unflag_long' => '',
       'unflag_message' => '',
       'unflag_denied_text' => '',
-      // The link type used by the flag, as defined in hook_flag_link_type_info().
+      // The link type used by the flag, as defined in
+      // hook_flag_link_type_info().
       'link_type' => 'toggle',
       'weight' => 0,
     );
@@ -245,7 +249,8 @@ class flag_flag {
    */
   function form_input($form_values) {
     // Load the form fields indiscriminately unto the flag (we don't care about
-    // stray FormAPI fields because we aren't touching unknown properties anyway.
+    // stray FormAPI fields because we aren't touching unknown properties
+    // anyway).
     foreach ($form_values as $field => $value) {
       $this->$field = $value;
     }
@@ -366,9 +371,9 @@ class flag_flag {
    * fetch_entity() return the remembered object.
    *
    * @param $entity_id
-   *  The ID of the object to cache.
+   *   The ID of the object to cache.
    * @param $object
-   *  The object to cache.
+   *   The object to cache.
    */
   function remember_entity($entity_id, $object) {
     $this->fetch_entity($entity_id, $object);
@@ -405,7 +410,7 @@ class flag_flag {
    * Provides permissions for this flag.
    *
    * @return
-   *  An array of permissions for hook_permission().
+   *   An array of permissions for hook_permission().
    */
   function get_permissions() {
     return array(
@@ -626,18 +631,18 @@ class flag_flag {
    *   TRUE if the flag is enabled for this type and subtype.
    */
   function access_entity_enabled($entity_type, $content_subtype = NULL) {
-   $entity_type_matches = ($this->entity_type == $entity_type);
-   $sub_type_matches = FALSE;
-   if (!isset($content_subtype) || !count($this->types)) {
-     // Subtype automatically matches if we're not asked about it,
-     // or if the flag applies to all subtypes.
-     $sub_type_matches = TRUE;
-   }
-   else {
-     $sub_type_matches = in_array($content_subtype, $this->types);
-   }
-   return $entity_type_matches && $sub_type_matches;
- }
+    $entity_type_matches = ($this->entity_type == $entity_type);
+    $sub_type_matches = FALSE;
+    if (!isset($content_subtype) || !count($this->types)) {
+      // Subtype automatically matches if we're not asked about it,
+      // or if the flag applies to all subtypes.
+      $sub_type_matches = TRUE;
+    }
+    else {
+      $sub_type_matches = in_array($content_subtype, $this->types);
+    }
+    return $entity_type_matches && $sub_type_matches;
+  }
 
   /**
    * Determine whether the flag should show a flag link in entity links.
@@ -1043,7 +1048,7 @@ class flag_flag {
    *   The amount of counts to increasing. Defaults to 1.
    *
    * @private
-  */
+   */
   function _increase_count($entity_id, $number = 1) {
     db_merge('flag_counts')
       ->key(array(
@@ -1076,7 +1081,7 @@ class flag_flag {
    *   The amount of counts to decrease. Defaults to 1.
    *
    * @private
-  */
+   */
   function _decrease_count($entity_id, $number = 1) {
     // Delete rows with count 0, for data consistency and space-saving.
     // Done before the db_update() to prevent out-of-bounds errors on "count".
@@ -1164,6 +1169,7 @@ class flag_flag {
    * @param $entity_id
    *   The ID in whose context to interpret tokens. If not given, only global
    *   tokens will be substituted.
+   *
    * @return
    *   The processed label.
    */
@@ -1511,12 +1517,12 @@ class flag_flag {
    * @param $variables = array()
    *  An array of further variables to pass to theme('flag'). For the full list
    *  of parameters, see flag.tpl.php. Of particular interest:
-   *  - after_flagging: Set to TRUE if this flag link is being displayed as the result
-   *    of a flagging action.
+   *  - after_flagging: Set to TRUE if this flag link is being displayed as the
+   *    result of a flagging action.
    *  - errors: An array of error messages.
    *
    * @return
-   *  The HTML for the flag link.
+   *   The HTML for the flag link.
    */
   function theme($action, $entity_id, $variables = array()) {
     static $js_added = array();
diff --git a/includes/flag/flag_node.inc b/includes/flag/flag_node.inc
index 0b04d02..005c756 100644
--- a/includes/flag/flag_node.inc
+++ b/includes/flag/flag_node.inc
@@ -2,7 +2,7 @@
 
 /**
  * @file
- *   Contains the flag_node class.
+ * Contains the flag_node class.
  */
 
 /**
@@ -89,6 +89,7 @@ class flag_node extends flag_entity {
    *
    * @param $entity_id
    *   The nid for the content.
+   *
    * @return
    *   The tnid if available, the nid otherwise.
    */
diff --git a/includes/flag/flag_user.inc b/includes/flag/flag_user.inc
index 72dc201..7ebbe6f 100644
--- a/includes/flag/flag_user.inc
+++ b/includes/flag/flag_user.inc
@@ -2,7 +2,7 @@
 
 /**
  * @file
- *   Contains the flag_user class.
+ * Contains the flag_user class.
  */
 
 /**
diff --git a/includes/views/flag.views_convert.inc b/includes/views/flag.views_convert.inc
index ed8910d..206d5ca 100644
--- a/includes/views/flag.views_convert.inc
+++ b/includes/views/flag.views_convert.inc
@@ -57,6 +57,7 @@ function flag_views_convert($display, $type, &$view, $field, $id) {
           $new_rel = 'flag_content_rel';
           $flag_content_rel_user = 'current';
           break;
+
         case 'count':
           $new_field = array(
             'label' => $field['label'],
@@ -67,6 +68,7 @@ function flag_views_convert($display, $type, &$view, $field, $id) {
           );
           $new_rel = 'flag_counts_rel';
           break;
+
         case 'name':
           $new_field = array(
             'label' => $field['label'],
@@ -95,6 +97,7 @@ function flag_views_convert($display, $type, &$view, $field, $id) {
           // Remove the old filter.
           $view->set_item('default', $type, $id, NULL);
           break;
+
         case 'timestamp':
           $new_field = array(
             'operator' => $field['operator'],
@@ -109,6 +112,7 @@ function flag_views_convert($display, $type, &$view, $field, $id) {
           $new_rel = 'flag_content_rel';
           drupal_set_message(t('Flag is not able to convert the <em>Flagged time</em> filter. It\'s value is currently empty, but needs to be populated to work properly.'), 'warning');
           break;
+
         case 'count':
           $new_field = array(
             'operator' => $field['operator'],
@@ -151,6 +155,7 @@ function flag_views_convert($display, $type, &$view, $field, $id) {
           );
           $new_rel = 'flag_counts_rel';
           break;
+
         case 'timestamp':
           $new_field = array(
             'order' => $field['sortorder'],
diff --git a/includes/views/flag_handler_argument_entity_id.inc b/includes/views/flag_handler_argument_entity_id.inc
index f5d3b1a..21ccf8a 100644
--- a/includes/views/flag_handler_argument_entity_id.inc
+++ b/includes/views/flag_handler_argument_entity_id.inc
@@ -27,12 +27,13 @@ class flag_handler_argument_entity_id extends views_handler_argument_numeric {
    */
   function title_query() {
     if (!($flag = $this->get_flag())) {
-      return array(); // Error message is printed by get_flag().
+      // Error message is printed by get_flag().
+      return array();
     }
     $views_info = $flag->get_views_info();
 
     $titles = array();
-    $placeholders = implode(', ', array_fill(0, sizeof($this->value), '%d'));
+    $placeholders = implode(', ', array_fill(0, count($this->value), '%d'));
 
     $result = db_select($views_info['views table'], 'o')
       ->fields('o', array($views_info['title field']))
diff --git a/includes/views/flag_handler_field_ops.inc b/includes/views/flag_handler_field_ops.inc
index 58830f1..125af26 100644
--- a/includes/views/flag_handler_field_ops.inc
+++ b/includes/views/flag_handler_field_ops.inc
@@ -35,7 +35,8 @@ class flag_handler_field_ops extends views_handler_field {
   function get_parent_relationship() {
     $parent = $this->view->relationship[$this->options['relationship']]->options['relationship'];
     if (!$parent || $parent == 'none') {
-      return NULL; // Base query table.
+      // Base query table.
+      return NULL;
     }
     else {
       return $this->view->relationship[$parent]->alias;
@@ -66,7 +67,8 @@ class flag_handler_field_ops extends views_handler_field {
    */
   function query() {
     if (!($flag = $this->get_flag())) {
-      return; // Error message is printed in render().
+      // Error message is printed in render().
+      return;
     }
     $info = $flag->get_views_info();
     $parent = $this->get_parent_relationship();
@@ -128,7 +130,8 @@ class flag_handler_field_ops extends views_handler_field {
    */
   function pre_render(&$values) {
     if (!($flag = $this->get_flag())) {
-      return; // Error message is printed in render().
+      // Error message is printed in render().
+      return;
     }
 
     $ids = array();
@@ -144,7 +147,8 @@ class flag_handler_field_ops extends views_handler_field {
 
   function render($values) {
     if (!($flag = $this->get_flag())) {
-      return t('Missing flag'); // get_flag() itself will print a more detailed message.
+      // get_flag() itself will print a more detailed message.
+      return t('Missing flag');
     }
 
     $entity_id = $values->{$this->aliases['entity_id']};
diff --git a/includes/views/flag_handler_filter_flagged.inc b/includes/views/flag_handler_filter_flagged.inc
index d22c40b..494859f 100644
--- a/includes/views/flag_handler_filter_flagged.inc
+++ b/includes/views/flag_handler_filter_flagged.inc
@@ -21,7 +21,11 @@ class flag_handler_filter_flagged extends views_handler_filter_boolean_operator
     parent::options_form($form, $form_state);
     $form['value']['#type'] = 'radios';
     $form['value']['#title'] = t('Status');
-    $form['value']['#options'] = array(1 => t('Flagged'), 0 => t('Not flagged'), 'All' => t('All'));
+    $form['value']['#options'] = array(
+      1 => t('Flagged'),
+      0 => t('Not flagged'),
+      'All' => t('All'),
+    );
     $form['value']['#default_value'] = empty($this->options['value']) ? '0' : $this->options['value'];
     $form['value']['#description'] = '<p>' . t('This filter is only needed if the relationship used has the "Include only flagged content" option <strong>unchecked</strong>. Otherwise, this filter is useless, because all records are already limited to flagged content.') . '</p><p>' . t('By choosing <em>Not flagged</em>, it is possible to create a list of content <a href="@unflagged-url">that is specifically not flagged</a>.', array('@unflagged-url' => 'http://drupal.org/node/299335')) . '</p>';
   }
diff --git a/includes/views/flag_handler_relationships.inc b/includes/views/flag_handler_relationships.inc
index 9a7c964..0ee05fc 100644
--- a/includes/views/flag_handler_relationships.inc
+++ b/includes/views/flag_handler_relationships.inc
@@ -264,4 +264,3 @@ class flag_handler_relationship_user_content extends flag_handler_relationship {
     parent::query();
   }
 }
-
diff --git a/includes/views/flag_handler_sort_flagged.inc b/includes/views/flag_handler_sort_flagged.inc
index 63c2787..d02719c 100644
--- a/includes/views/flag_handler_sort_flagged.inc
+++ b/includes/views/flag_handler_sort_flagged.inc
@@ -14,7 +14,8 @@ class flag_handler_sort_flagged extends views_handler_sort {
 
   /**
    * Provide a list of options for the default sort form.
-   * Should be overridden by classes that don't override sort_form
+   * 
+   * Should be overridden by classes that don't override sort_form.
    */
   function sort_options() {
     return array(
diff --git a/includes/views/flag_plugin_argument_validate_flaggability.inc b/includes/views/flag_plugin_argument_validate_flaggability.inc
index f653412..7cd5269 100644
--- a/includes/views/flag_plugin_argument_validate_flaggability.inc
+++ b/includes/views/flag_plugin_argument_validate_flaggability.inc
@@ -66,8 +66,9 @@ class flag_plugin_argument_validate_flaggability extends views_plugin_argument_v
   }
 
   /**
-   * Returns form #options for the flags. Returns empty array if no flags were
-   * found.
+   * Returns form #options for the flags.
+   *
+   * Returns empty array if no flags were found.
    */
   function flags_options() {
     $flags = flag_get_flags($this->flag_type);
@@ -96,8 +97,9 @@ class flag_plugin_argument_validate_flaggability extends views_plugin_argument_v
   }
 
   /**
-   * Declares all tests. This scheme makes it easy for derived classes to add
-   * and remove tests.
+   * Declares all tests.
+   *
+   * This scheme makes it easy for derived classes to add and remove tests.
    */
   function tests_info($which = NULL) {
     return array(
@@ -130,7 +132,8 @@ class flag_plugin_argument_validate_flaggability extends views_plugin_argument_v
     if ($flag_name == '*relationship*') {
       // Pick the first flag mentioned in the relationships.
       foreach ($this->view->relationship as $id => $handler) {
-        // Note: we can't do $handler->field, because the relationship handler's init() may overwrite it.
+        // Note: we can't do $handler->field, because the relationship handler's
+        // init() may overwrite it.
         if (strpos($handler->options['field'], 'flag') !== FALSE && !empty($handler->options['flag'])) {
           $flag = flag_get_flag($handler->options['flag']);
           if ($flag && $flag->entity_type == $this->flag_type) {
@@ -198,7 +201,8 @@ class flag_plugin_argument_validate_flaggability extends views_plugin_argument_v
   }
 
   function test_flagged($ids, $flag) {
-    // view_break_phrase() is guaranteed to return only integers, so this is SQL safe.
+    // view_break_phrase() is guaranteed to return only integers, so this is SQL
+    // safe.
     $flattened_ids = implode(',', $ids);
     return $this->_test_by_sql("SELECT entity_id FROM {flag_counts} WHERE fid = :fid AND entity_id IN ($flattened_ids) AND count > 0", array(':fid' => $flag->fid));
   }
@@ -206,7 +210,7 @@ class flag_plugin_argument_validate_flaggability extends views_plugin_argument_v
   function test_flagged_by_current_user($ids, $flag) {
     global $user;
     if (!$user->uid) {
-      // Anonymous user
+      // Anonymous user.
       return array();
     }
     $flattened_ids = implode(',', $ids);
@@ -223,4 +227,3 @@ class flag_plugin_argument_validate_flaggability extends views_plugin_argument_v
     return $passed;
   }
 }
-
diff --git a/plugins/access/flag_is_flagged/flag_is_flagged.inc b/plugins/access/flag_is_flagged/flag_is_flagged.inc
index 720e612..0f6e043 100644
--- a/plugins/access/flag_is_flagged/flag_is_flagged.inc
+++ b/plugins/access/flag_is_flagged/flag_is_flagged.inc
@@ -31,7 +31,7 @@ function flag_flag_is_flagged_access_get_children($plugin, $parent) {
 
   foreach ($entities as $entity_type => $info) {
     if (entity_type_supports($entity_type, 'view')) {
-      $plugin['title'] =  t('@entity_type is flagged', array('@entity_type' => $info['label']));
+      $plugin['title'] = t('@entity_type is flagged', array('@entity_type' => $info['label']));
       $plugin['keyword'] = $entity_type;
       $plugin['name'] = $parent . ':' . $entity_type;
       $plugin['required context'] = new ctools_context_required(t('Entity'), $entity_type);
@@ -103,7 +103,7 @@ function flag_flag_is_flagged_access_check($conf, $context) {
 }
 
 /**
- * Provide a summary description based upon the specified context
+ * Provide a summary description based upon the specified context.
  */
 function flag_flag_is_flagged_access_summary($conf, $context) {
   $flag = flag_get_flag($conf['flag_name']);
diff --git a/tests/flag.test b/tests/flag.test
index 589e036..29b20a5 100644
--- a/tests/flag.test
+++ b/tests/flag.test
@@ -14,10 +14,10 @@ abstract class FlagTestCaseBase extends DrupalWebTestCase {
    * Helper to create a flag from an array of data and clear caches etc.
    *
    * @param $flag_data
-   *  An array of flag data.
+   *   An array of flag data.
    *
    * @return
-   *  The flag object.
+   *   The flag object.
    */
   function createFlag($flag_data) {
     $flag = flag_flag::factory_by_array($flag_data);
@@ -216,7 +216,7 @@ class FlagFlaggingCRUDTestCase extends FlagTestCaseBase {
  * Test Flag admin UI.
  */
 class FlagAdminTestCase extends FlagTestCaseBase {
-  var $_flag = FALSE;
+  public $_flag = FALSE;
 
   /**
    * Implements getInfo().
@@ -235,7 +235,7 @@ class FlagAdminTestCase extends FlagTestCaseBase {
   function setUp() {
     parent::setUp('flag');
 
-    // Create and login user
+    // Create and login user.
     $admin_user = $this->drupalCreateUser(array('access administration pages', 'administer flags'));
     $this->drupalLogin($admin_user);
   }
@@ -277,7 +277,13 @@ class FlagAdminTestCase extends FlagTestCaseBase {
     $saved = $edit;
     $saved['roles'] = array('flag' => array(2), 'unflag' => array(2));
     $saved['types'] = array('page');
-    $saved['show_in_links'] = array('full' => 0, 'teaser' => 0, 'rss' => 0, 'search_index' => 0, 'search_result' => 0);
+    $saved['show_in_links'] = array(
+      'full' => 0,
+      'teaser' => 0,
+      'rss' => 0,
+      'search_index' => 0,
+      'search_result' => 0,
+    );
     unset($saved['roles[flag][2]'], $saved['roles[unflag][2]'], $saved['types[article]'], $saved['types[page]'], $saved['show_in_links[full]'], $saved['show_in_links[teaser]'], $saved['show_in_links[rss]'], $saved['show_in_links[search_index]'], $saved['show_in_links[search_result]']);
 
     $this->drupalPost(FLAG_ADMIN_PATH . '/add/node', $edit, t('Save flag'));
@@ -299,7 +305,7 @@ class FlagAdminTestCase extends FlagTestCaseBase {
     $permissions = user_role_permissions(user_roles());
     foreach ($saved['roles'] as $action => $rids) {
       foreach ($rids as $rid) {
-        $permission_string = "$action ". $saved['name'];
+        $permission_string = "$action " . $saved['name'];
         $this->assertTrue(isset($permissions[$rid][$permission_string]), t('Permission %perm set for flag.', array(
           '%perm' => $permission_string,
         )));
@@ -331,7 +337,13 @@ class FlagAdminTestCase extends FlagTestCaseBase {
     $saved = $edit;
     $saved['roles'] = array('flag' => array(2), 'unflag' => array(2));
     $saved['types'] = array('article');
-    $saved['show_in_links'] = array('full' => TRUE, 'teaser' => TRUE, 'rss' => 0, 'search_index' => 0, 'search_result' => 0);
+    $saved['show_in_links'] = array(
+      'full' => TRUE,
+      'teaser' => TRUE,
+      'rss' => 0,
+      'search_index' => 0,
+      'search_result' => 0,
+    );
     unset($saved['roles[flag][2]'], $saved['roles[unflag][2]'], $saved['types[article]'], $saved['types[page]'], $saved['show_in_links[full]'], $saved['show_in_links[teaser]'], $saved['show_in_links[rss]'], $saved['show_in_links[search_index]'], $saved['show_in_links[search_result]']);
 
     $this->drupalPost(FLAG_ADMIN_PATH . '/manage/' . $flag->name, $edit, t('Save flag'));
@@ -358,7 +370,7 @@ class FlagAdminTestCase extends FlagTestCaseBase {
 
     foreach ($saved['roles'] as $action => $rids) {
       foreach ($rids as $rid) {
-        $permission_string = "$action ". $saved['name'];
+        $permission_string = "$action " . $saved['name'];
         $this->assertTrue(isset($permissions[$rid][$permission_string]), t('Permission %perm set for flag.', array(
           '%perm' => $permission_string,
         )));
@@ -439,7 +451,7 @@ class FlagAccessFormTestCase extends FlagTestCaseBase {
 
     $this->drupalGet('node/add/article');
 
-    // Check that the flag form element cannot be seen
+    // Check that the flag form element cannot be seen.
     $this->assertNoText('Flag this item', t('Flag form element was not found.'));
 
     // Have the user create a node.
@@ -538,13 +550,13 @@ class FlagEntityTokensTestCase extends FlagTestCaseBase {
     node_save($node);
 
     // Flag it by several users.
-    $flag_user_1 = $this->drupalCreateUser(array('flag node_flag',));
+    $flag_user_1 = $this->drupalCreateUser(array('flag node_flag'));
 
     // Flag the node as the user.
     $flag = flag_get_flag('node_flag');
     $flag->flag('flag', $node->nid, $flag_user_1);
 
-    $flag_user_2 = $this->drupalCreateUser(array('flag node_flag',));
+    $flag_user_2 = $this->drupalCreateUser(array('flag node_flag'));
 
     // Flag the node as the user.
     $flag->flag('flag', $node->nid, $flag_user_2);
@@ -603,13 +615,13 @@ class FlagEntityTokensTestCase extends FlagTestCaseBase {
     taxonomy_term_save($term);
 
     // Flag it by several users.
-    $flag_user_1 = $this->drupalCreateUser(array('flag term_flag',));
+    $flag_user_1 = $this->drupalCreateUser(array('flag term_flag'));
 
     // Flag the term as the user.
     $flag = flag_get_flag('term_flag');
     $flag->flag('flag', $term->tid, $flag_user_1);
 
-    $flag_user_2 = $this->drupalCreateUser(array('flag term_flag',));
+    $flag_user_2 = $this->drupalCreateUser(array('flag term_flag'));
 
     // Flag the term as the user.
     $flag = flag_get_flag('term_flag');
@@ -712,7 +724,7 @@ class FlagAccessLinkTestCase extends FlagTestCaseBase {
    */
   function testFlagAccessFlagOnly() {
     // Create test user who can flag but not unflag.
-    $flag_user = $this->drupalCreateUser(array('flag test_flag',));
+    $flag_user = $this->drupalCreateUser(array('flag test_flag'));
     $this->drupalLogin($flag_user);
 
     // Look at our node.
@@ -1002,7 +1014,8 @@ class FlagHookFlagAccessTestCase extends FlagTestCaseBase {
   }
 
   /**
-   * Verifies that the user sees the flag if a module returns TRUE (Allow) to override default access check.
+   * Verifies that the user sees the flag if a module returns TRUE (Allow) to
+   * override default access check.
    */
   function testFlagAccessAllowOverride() {
     variable_set('FlagHookFlagAccessTestCaseMode', 'allow');
@@ -1026,7 +1039,8 @@ class FlagHookFlagAccessTestCase extends FlagTestCaseBase {
   }
 
   /**
-   * Verifies that the user does not see the flag if a module returns FALSE (Deny).
+   * Verifies that the user does not see the flag if a module returns FALSE
+   * (Deny).
    */
   function testFlagAccessDeny() {
     variable_set('FlagHookFlagAccessTestCaseMode', 'deny');
@@ -1050,7 +1064,7 @@ class FlagEntityFieldQueryTestCase extends FlagTestCaseBase {
    * Implements getInfo().
    */
   public static function getInfo() {
-     return array(
+    return array(
       'name' => 'Entity Field Query',
       'description' => 'Entity Field Query for flagging entities.',
       'group' => 'Flag',
@@ -1099,7 +1113,12 @@ class FlagEntityFieldQueryTestCase extends FlagTestCaseBase {
     $this->flag3 = $this->createFlag($flag_data);
 
     // Create test user who can flag and unflag.
-    $this->flag_unflag_user = $this->drupalCreateUser(array('flag test_flag_1', 'unflag test_flag_1', 'flag test_flag_2', 'unflag test_flag_2'));
+    $this->flag_unflag_user = $this->drupalCreateUser(array(
+      'flag test_flag_1',
+      'unflag test_flag_1',
+      'flag test_flag_2',
+      'unflag test_flag_2',
+    ));
     $this->drupalLogin($this->flag_unflag_user);
 
   }
@@ -1108,7 +1127,7 @@ class FlagEntityFieldQueryTestCase extends FlagTestCaseBase {
    * Test use of EntityFieldQuery with flagging entities.
    */
   function testEntityFieldQuery() {
-     $node_settings = array(
+    $node_settings = array(
       'title' => $this->randomName(),
       'body' => array(LANGUAGE_NONE => array(array('value' => $this->randomName(32)))),
       'uid' => 1,
@@ -1150,7 +1169,7 @@ class FlagHookInvocationsTestCase extends FlagTestCaseBase {
    * Implements getInfo().
    */
   public static function getInfo() {
-     return array(
+    return array(
       'name' => 'Hook invocations',
       'description' => 'Invocation of flag and entity hooks and rules during flagging and unflagging.',
       'group' => 'Flag',
@@ -1202,8 +1221,6 @@ class FlagHookInvocationsTestCase extends FlagTestCaseBase {
 
     // Get the variable the test module sets the hook order into.
     $hook_data_variable = variable_get('flag_hook_test_hook_tracking', array());
-    //debug($hook_data_variable['hook_entity_presave']);
-    //debug($hook_data_variable['hook_entity_insert']);
 
     $expected_hook_order = array(
       'hook_entity_presave',
@@ -1221,15 +1238,12 @@ class FlagHookInvocationsTestCase extends FlagTestCaseBase {
     // the things that do get passed.
     // See https://drupal.org/node/2196055.
     $this->assertEqual($hook_data_variable['hook_entity_presave']['parameters'][0]->flag_name, $flag->name, "The Flagging entity passed to hook_entity_presave() has the expected flag name property.");
-    //$this->assertEqual($hook_data_variable['hook_entity_insert']['parameters'][0]->fid, $flag->fid);
-    //$this->assertEqual($hook_data_variable['hook_entity_insert']['parameters'][0]->entity_type, 'node');
     $this->assertEqual($hook_data_variable['hook_entity_presave']['parameters'][0]->entity_id, $node->nid, "The Flagging entity passed to hook_entity_presave() has the expected entity ID property.");
     $this->assertEqual($hook_data_variable['hook_entity_presave']['parameters'][0]->uid, $this->flag_unflag_user->uid, "The Flagging entity passed to hook_entity_presave() has the expected uid property.");
     // Param 1: $entity_type.
     $this->assertEqual($hook_data_variable['hook_entity_presave']['parameters'][1], 'flagging', "hook_entity_presave() is passed the correct entity type.");
 
     // Check the API data available to hook_entity_presave().
-    //debug($hook_data_variable['hook_entity_presave']['api_calls']);
     $this->assertEqual($hook_data_variable['hook_entity_presave']['api_calls']['flag_get_entity_flags'], array(), "hook_entity_presave() gets no data from from flag_get_entity_flags(), as the flagging has not yet taken place.");
     $this->assertEqual($hook_data_variable['hook_entity_presave']['api_calls']['flag_get_user_flags'], array(), "hook_entity_presave() gets no data from from flag_get_user_flags(), as the flagging has not yet taken place.");
     // The flag counts have not yet been increased.
@@ -1242,8 +1256,6 @@ class FlagHookInvocationsTestCase extends FlagTestCaseBase {
     // Param 0: $flagging.
     // See https://drupal.org/node/2196055.
     $this->assertEqual($hook_data_variable['hook_entity_insert']['parameters'][0]->flag_name, $flag->name, "The Flagging entity passed to hook_entity_insert() has the expected flag name property.");
-    //$this->assertEqual($hook_data_variable['hook_entity_insert']['parameters'][0]->fid, $flag->fid);
-    //$this->assertEqual($hook_data_variable['hook_entity_insert']['parameters'][0]->entity_type, 'node');
     $this->assertEqual($hook_data_variable['hook_entity_insert']['parameters'][0]->entity_id, $node->nid, "The Flagging entity passed to hook_entity_insert() has the expected entity ID property.");
     $this->assertEqual($hook_data_variable['hook_entity_insert']['parameters'][0]->uid, $this->flag_unflag_user->uid, "The Flagging entity passed to hook_entity_insert() has the expected uid property.");
     $this->assertTrue(!empty($hook_data_variable['hook_entity_insert']['parameters'][0]->flagging_id), "The Flagging entity passed to hook_entity_insert() has the flagging ID set.");
@@ -1251,7 +1263,6 @@ class FlagHookInvocationsTestCase extends FlagTestCaseBase {
     $this->assertEqual($hook_data_variable['hook_entity_insert']['parameters'][1], 'flagging', "hook_entity_insert() is passed the correct entity type.");
 
     // Check the API data available to hook_entity_insert().
-    //debug($hook_data_variable['hook_entity_insert']['api_calls']);
     $flag_get_entity_flags = $hook_data_variable['hook_entity_insert']['api_calls']['flag_get_entity_flags'];
     $flag_get_entity_flags_uids = array_keys($flag_get_entity_flags);
     $this->assertEqual($flag_get_entity_flags_uids, array($this->flag_unflag_user->uid), "hook_entity_insert() gets correct data for flagging users from flag_get_entity_flags()");
@@ -1289,13 +1300,10 @@ class FlagHookInvocationsTestCase extends FlagTestCaseBase {
     // Param 3: $flagging.
     // See https://drupal.org/node/2196055.
     $this->assertEqual($hook_data_variable['hook_flag_flag']['parameters'][3]->flag_name, $flag->name, "The Flagging entity passed to hook_flag_flag() has the expected flag name property.");
-    //$this->assertEqual($hook_data_variable['hook_entity_insert']['parameters'][3]->fid, $flag->fid);
-    //$this->assertEqual($hook_data_variable['hook_entity_insert']['parameters'][3]->entity_type, 'node');
     $this->assertEqual($hook_data_variable['hook_flag_flag']['parameters'][3]->entity_id, $node->nid, "The Flagging entity passed to hook_flag_flag() has the expected entity ID property.");
     $this->assertEqual($hook_data_variable['hook_flag_flag']['parameters'][3]->uid, $this->flag_unflag_user->uid, "The Flagging entity passed to hook_flag_flag() has the expected uid property.");
 
     // Check the API data available to hook_flag_flag().
-    //debug($hook_data_variable['hook_flag_flag']['api_calls']);
     $flag_get_entity_flags = $hook_data_variable['hook_flag_flag']['api_calls']['flag_get_entity_flags'];
     $flag_get_entity_flags_uids = array_keys($flag_get_entity_flags);
     $this->assertEqual($flag_get_entity_flags_uids, array($this->flag_unflag_user->uid), "hook_flag_flag() gets correct data for flagging users from flag_get_entity_flags()");
@@ -1345,7 +1353,6 @@ class FlagHookInvocationsTestCase extends FlagTestCaseBase {
 
     // Get the variable the test module sets the hook order into.
     $hook_data_variable = variable_get('flag_hook_test_hook_tracking', array());
-    //debug($hook_data_variable);
 
     $expected_hook_order = array(
       'hook_entity_presave',
@@ -1363,15 +1370,12 @@ class FlagHookInvocationsTestCase extends FlagTestCaseBase {
     // the things that do get passed.
     // See https://drupal.org/node/2196055.
     $this->assertEqual($hook_data_variable['hook_entity_presave']['parameters'][0]->flag_name, $flag->name, "The Flagging entity passed to hook_entity_presave() has the expected flag name property.");
-    //$this->assertEqual($hook_data_variable['hook_entity_insert']['parameters'][0]->fid, $flag->fid);
-    //$this->assertEqual($hook_data_variable['hook_entity_insert']['parameters'][0]->entity_type, 'node');
     $this->assertEqual($hook_data_variable['hook_entity_presave']['parameters'][0]->entity_id, $node->nid, "The Flagging entity passed to hook_entity_presave() has the expected entity ID property.");
     $this->assertEqual($hook_data_variable['hook_entity_presave']['parameters'][0]->uid, $this->flag_unflag_user->uid, "The Flagging entity passed to hook_entity_presave() has the expected uid property.");
     // Param 1: $entity_type.
     $this->assertEqual($hook_data_variable['hook_entity_presave']['parameters'][1], 'flagging', "hook_entity_presave() is passed the correct entity type.");
 
     // Check the API data available to hook_entity_presave().
-    //debug($hook_data_variable['hook_entity_presave']['api_calls']);
     $flag_get_entity_flags = $hook_data_variable['hook_entity_presave']['api_calls']['flag_get_entity_flags'];
     $flag_get_entity_flags_uids = array_keys($flag_get_entity_flags);
     $this->assertEqual($flag_get_entity_flags_uids, array($this->flag_unflag_user->uid), "hook_entity_presave() gets correct data for flagging users from flag_get_entity_flags()");
@@ -1403,8 +1407,6 @@ class FlagHookInvocationsTestCase extends FlagTestCaseBase {
     // Param 0: $flagging.
     // See https://drupal.org/node/2196055.
     $this->assertEqual($hook_data_variable['hook_entity_update']['parameters'][0]->flag_name, $flag->name, "The Flagging entity passed to hook_entity_update() has the expected flag name property.");
-    //$this->assertEqual($hook_data_variable['hook_entity_update']['parameters'][0]->fid, $flag->fid);
-    //$this->assertEqual($hook_data_variable['hook_entity_update']['parameters'][0]->entity_type, 'node');
     $this->assertEqual($hook_data_variable['hook_entity_update']['parameters'][0]->entity_id, $node->nid, "The Flagging entity passed to hook_entity_update() has the expected entity ID property.");
     $this->assertEqual($hook_data_variable['hook_entity_update']['parameters'][0]->uid, $this->flag_unflag_user->uid, "The Flagging entity passed to hook_entity_update() has the expected uid property.");
     $this->assertTrue(!empty($hook_data_variable['hook_entity_update']['parameters'][0]->flagging_id), "The Flagging entity passed to hook_entity_update() has the flagging ID set.");
@@ -1412,7 +1414,6 @@ class FlagHookInvocationsTestCase extends FlagTestCaseBase {
     $this->assertEqual($hook_data_variable['hook_entity_update']['parameters'][1], 'flagging', "hook_entity_update() is passed the correct entity type.");
 
     // Check the API data available to hook_entity_update().
-    //debug($hook_data_variable['hook_entity_update']['api_calls']);
     $flag_get_entity_flags = $hook_data_variable['hook_entity_update']['api_calls']['flag_get_entity_flags'];
     $flag_get_entity_flags_uids = array_keys($flag_get_entity_flags);
     $this->assertEqual($flag_get_entity_flags_uids, array($this->flag_unflag_user->uid), "hook_entity_update() gets correct data for flagging users from flag_get_entity_flags()");
@@ -1448,7 +1449,6 @@ class FlagHookInvocationsTestCase extends FlagTestCaseBase {
 
     // Get the variable the test module sets the hook order into.
     $hook_data_variable = variable_get('flag_hook_test_hook_tracking', array());
-    //debug($hook_data_variable);
 
     $expected_hook_order = array(
       'hook_flag_unflag',
@@ -1469,13 +1469,10 @@ class FlagHookInvocationsTestCase extends FlagTestCaseBase {
     // Param 3: $flagging.
     // See https://drupal.org/node/2196055.
     $this->assertEqual($hook_data_variable['hook_flag_unflag']['parameters'][3]->flag_name, $flag->name, "The Flagging entity passed to hook_flag_unflag() has the expected flag name property.");
-    //$this->assertEqual($hook_data_variable['hook_entity_insert']['parameters'][3]->fid, $flag->fid);
-    //$this->assertEqual($hook_data_variable['hook_entity_insert']['parameters'][3]->entity_type, 'node');
     $this->assertEqual($hook_data_variable['hook_flag_unflag']['parameters'][3]->entity_id, $node->nid, "The Flagging entity passed to hook_flag_unflag() has the expected entity ID property.");
     $this->assertEqual($hook_data_variable['hook_flag_unflag']['parameters'][3]->uid, $this->flag_unflag_user->uid, "The Flagging entity passed to hook_flag_unflag() has the expected uid property.");
 
     // Check the API data available to hook_flag_unflag().
-    //debug($hook_data_variable['hook_flag_unflag']['api_calls']);
     // The unflagging is not yet done, so flag_get_entity_flags() will find the
     // flagging data.
     $flag_get_entity_flags = $hook_data_variable['hook_flag_unflag']['api_calls']['flag_get_entity_flags'];
@@ -1513,8 +1510,6 @@ class FlagHookInvocationsTestCase extends FlagTestCaseBase {
     // Param 0: $flagging.
     // See https://drupal.org/node/2196055.
     $this->assertEqual($hook_data_variable['hook_entity_delete']['parameters'][0]->flag_name, $flag->name, "The Flagging entity passed to hook_entity_delete() has the expected flag name property.");
-    //$this->assertEqual($hook_data_variable['hook_entity_delete']['parameters'][0]->fid, $flag->fid);
-    //$this->assertEqual($hook_data_variable['hook_entity_delete']['parameters'][0]->entity_type, 'node');
     $this->assertEqual($hook_data_variable['hook_entity_delete']['parameters'][0]->entity_id, $node->nid, "The Flagging entity passed to hook_entity_delete() has the expected entity ID property.");
     $this->assertEqual($hook_data_variable['hook_entity_delete']['parameters'][0]->uid, $this->flag_unflag_user->uid, "The Flagging entity passed to hook_entity_delete() has the expected uid property.");
     $this->assertTrue(!empty($hook_data_variable['hook_entity_delete']['parameters'][0]->flagging_id), "The Flagging entity passed to hook_entity_delete() has the flagging ID set.");
@@ -1522,7 +1517,6 @@ class FlagHookInvocationsTestCase extends FlagTestCaseBase {
     $this->assertEqual($hook_data_variable['hook_entity_delete']['parameters'][1], 'flagging', "hook_entity_delete() is passed the correct entity type.");
 
     // Check the API data available to hook_entity_delete().
-    //debug($hook_data_variable['hook_entity_delete']['api_calls']);
     // The unflagging is not yet done, so hook_entity_delete() will find the
     // flagging data.
     $flag_get_entity_flags = $hook_data_variable['hook_entity_delete']['api_calls']['flag_get_entity_flags'];
diff --git a/tests/flag_hook_test/flag_hook_test.module b/tests/flag_hook_test/flag_hook_test.module
index 688f801..0054e9e 100644
--- a/tests/flag_hook_test/flag_hook_test.module
+++ b/tests/flag_hook_test/flag_hook_test.module
@@ -1,7 +1,7 @@
 <?php
 
 /**
- * @file flag_hook_test.module
+ * @file
  * Test module for the hooks that Flag invokes.
  */
 
@@ -11,13 +11,13 @@
  * Hook implementations should call this with their hook name and parameters.
  *
  * @param $hook_name
- *  The name of the hook invoked.
+ *   The name of the hook invoked.
  * @param $function_parameters
- *  The array of parameters the hook received.
+ *   The array of parameters the hook received.
  * @param $flagging
- *  (optional) The flagging entity that the hook received. If this is given,
- *  then various flag API functions have their data set into the tracking
- *  variable for verification by the test case.
+ *   (optional) The flagging entity that the hook received. If this is given,
+ *   then various flag API functions have their data set into the tracking
+ *   variable for verification by the test case.
  */
 function _flag_hook_test_record_invocation($hook_name, $function_parameters, $flagging = NULL) {
   $variable = variable_get('flag_hook_test_hook_tracking', array());
@@ -99,18 +99,18 @@ function flag_hook_test_entity_delete($entity, $type) {
   }
 }
 
-// ========================================================= Configuration
+// ========================================================= Configuration.
 
 /**
  * Implements hook_flag_default_flags().
  */
 function flag_hook_test_flag_default_flags() {
   $flags = array();
-  $flags['flag_hook_test_flag'] = array (
+  $flags['flag_hook_test_flag'] = array(
     'entity_type' => 'node',
     'title' => 'Test Flag',
     'global' => FALSE,
-    'types' => array (
+    'types' => array(
       0 => 'article',
     ),
     'flag_short' => 'Flag this',
@@ -122,7 +122,7 @@ function flag_hook_test_flag_default_flags() {
     'unflag_denied_text' => 'You may not unflag this item',
     'link_type' => 'normal',
     'weight' => 0,
-    'show_in_links' => array (
+    'show_in_links' => array(
       'full' => TRUE,
       'teaser' => TRUE,
     ),
diff --git a/theme/flag.tpl.php b/theme/flag.tpl.php
index 60a3113..3ef95aa 100644
--- a/theme/flag.tpl.php
+++ b/theme/flag.tpl.php
@@ -2,28 +2,33 @@
 
 /**
  * @file
- * Default theme implementation to display a flag link, and a message after the action
- * is carried out.
+ * Default theme implementation to display a flag link, and a message after the
+ * action is carried out.
  *
  * Available variables:
  *
  * - $flag: The flag object itself. You will only need to use it when the
  *   following variables don't suffice.
- * - $flag_name_css: The flag name, with all "_" replaced with "-". For use in 'class'
- *   attributes.
- * - $flag_classes: A space-separated list of CSS classes that should be applied to the link.
+ * - $flag_name_css: The flag name, with all "_" replaced with "-". For use in
+ *   'class' attributes.
+ * - $flag_classes: A space-separated list of CSS classes that should be applied
+ *   to the link.
  *
- * - $action: The action the link is about to carry out, either "flag" or "unflag".
+ * - $action: The action the link is about to carry out, either "flag" or
+ *   "unflag".
  * - $status: The status of the item; either "flagged" or "unflagged".
  *
  * - $link_href: The URL for the flag link.
  * - $link_text: The text to show for the link.
  * - $link_title: The title attribute for the link.
  *
- * - $message_text: The long message to show after a flag action has been carried out.
- * - $message_classes: A space-separated list of CSS classes that should be applied to
+ * - $message_text: The long message to show after a flag action has been
+ *   carried out.
+ * - $message_classes: A space-separated list of CSS classes that should be
+ *   applied to
  *   the message.
- * - $after_flagging: This template is called for the link both before and after being
+ * - $after_flagging: This template is called for the link both before and after
+ *   being
  *   flagged. If displaying to the user immediately after flagging, this value
  *   will be boolean TRUE. This is usually used in conjunction with immedate
  *   JavaScript-based toggling of flags.
@@ -35,8 +40,8 @@
  * - flag--name.tpl.php
  * - flag--link-type.tpl.php
  *
- * NOTE: This template spaces out the <span> tags for clarity only. When doing some
- * advanced theming you may have to remove all the whitespace.
+ * NOTE: This template spaces out the <span> tags for clarity only. When doing
+ * some advanced theming you may have to remove all the whitespace.
  */
 ?>
 <?php if ($needs_wrapping_element): ?>
