diff --git a/includes/registration.entity.inc b/includes/registration.entity.inc
index 5515f0a..24fa05c 100644
--- a/includes/registration.entity.inc
+++ b/includes/registration.entity.inc
@@ -255,7 +255,7 @@ class Registration extends Entity {
 
   /**
    * Determine registrant type relative to a given account
-   * 
+   *
    * @param $account
    *   A Drupal user
    *
@@ -267,10 +267,10 @@ class Registration extends Entity {
       if ($account->uid && $account->uid === $this->user_uid) {
         return REGISTRATION_REGISTRANT_TYPE_ME;
       }
-      else if($this->user_uid) {
+      elseif ($this->user_uid) {
         return REGISTRATION_REGISTRANT_TYPE_USER;
       }
-      else if(!empty($this->anon_mail)) {
+      elseif (!empty($this->anon_mail)) {
         return REGISTRATION_REGISTRANT_TYPE_ANON;
       }
     }
@@ -278,7 +278,7 @@ class Registration extends Entity {
 }
 
 /**
- * @see hook_entity_property_info().
+ * @see hook_entity_property_info()
  */
 class RegistrationMetadataController extends EntityDefaultMetadataController {
   public function entityPropertyInfo() {
@@ -402,7 +402,26 @@ function registration_save(Registration $registration) {
 }
 
 /**
- * Access callback for the entity API.
+ * Access callback: Entity API for Registration entities.
+ *
+ * Checks if a user has permission to execute an operation on a registration
+ * entity.
+ *
+ * Implements hook_registration_access(). Modules may return a boolean value,
+ * or NULL if they do not care one way or the other.
+ *
+ * @param string $op
+ *   Operation user wishes to perform.
+ * @param object $registration
+ *   (optional) A Fully loaded registration object.
+ * @param object $account
+ *   (optional) An user object, or omit for logged in user.
+ * @param string $entity_type
+ *   (optional) Entity type of $registration. Usually 'registration'.
+ *
+ * @return bool
+ *
+ * @see registration_entity_info()
  */
 function registration_access($op, $registration = NULL, $account = NULL, $entity_type) {
   $account = isset($account) ? $account : $GLOBALS['user'];
@@ -465,8 +484,7 @@ class RegistrationTypeUIController extends EntityDefaultUIController {
    */
   public function hook_menu() {
     $items = parent::hook_menu();
-		$items[$this->path]['description'] = 'Manage registration entity types, including adding
-		and removing fields and the display of fields.';
+    $items[$this->path]['description'] = t('Manage registration entity types, including adding and removing fields and the display of fields.');
     return $items;
   }
 }
diff --git a/includes/registration.field.inc b/includes/registration.field.inc
index df2d30a..83d6530 100644
--- a/includes/registration.field.inc
+++ b/includes/registration.field.inc
@@ -1,6 +1,11 @@
 <?php
 
 /**
+ * @file
+ * Field hooks.
+ */
+
+/**
  * Implements hook_field_info().
  */
 function registration_field_info() {
@@ -56,7 +61,7 @@ function registration_field_widget_info() {
  */
 function registration_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) {
   $options = array('' => t('-- Disable Registrations --'));
-  foreach(registration_get_types() as $type) {
+  foreach (registration_get_types() as $type) {
     $options[$type->name] = $type->label;
   }
   $element += array(
@@ -113,13 +118,13 @@ function registration_field_formatter_view($entity_type, $entity, $field, $insta
           $element[0] = array('#markup' => theme('registration_link',
             array(
               'label' => $reg_type->label,
-              'path'  => $uri['path']. '/register')
+              'path'  => $uri['path'] . '/register')
           ));
         }
         break;
       case 'registration_form':
         // enable registration link if accessible
-        list($entity_id, ,) = entity_extract_ids($entity_type, $entity);
+        list($entity_id) = entity_extract_ids($entity_type, $entity);
         if (registration_register_page_access($entity_type, $entity) && registration_status($entity_type, $entity_id)) {
           $registration = entity_get_controller('registration')->create(array('type' => $reg_type->name));
           $registration->entity_id = $entity_id;
@@ -186,7 +191,7 @@ function registration_form_field_ui_field_overview_form_alter(&$form, &$form_sta
 function registration_form_field_ui_field_overview_form_validate(&$form, &$form_state) {
   $fields = $form_state['values']['fields'];
   if ($fields['_add_new_field']['type'] == 'registration') {
-    foreach($form['#fields'] as $field_name) {
+    foreach ($form['#fields'] as $field_name) {
       $field = field_info_field($field_name);
       if ($field['type'] == 'registration') {
         form_set_error('_add_new_field', t('An entity can only have one registration field.'));
diff --git a/includes/registration.forms.inc b/includes/registration.forms.inc
index 0c3bde8..8603ce6 100644
--- a/includes/registration.forms.inc
+++ b/includes/registration.forms.inc
@@ -1,6 +1,11 @@
 <?php
 
 /**
+ * @file
+ * Forms
+ */
+
+/**
  * Form callback: create or edit a registration.
  *
  * @param $registration
@@ -64,7 +69,7 @@ function registration_form($form, &$form_state, Registration $registration) {
     '#title' => t('Slots'),
     '#description' => t('The number of slots you wish to occupy. @slots_remaining slots remaining.', array('@slots_remaining' => $remaining)),
     '#default_value' => 1,
-    '#size' => strlen($remaining),
+    '#size' => drupal_strlen($remaining),
     '#access' => isset($settings['settings']['multiple_registrations']) ? $settings['settings']['multiple_registrations'] : FALSE,
     '#element_validate' => array('element_validate_integer_positive')
   );
@@ -123,15 +128,15 @@ function registration_form_validate($form, &$form_state) {
         form_set_error('anon_mail', t('The email address is invalid.'));
       }
       if (registration_is_registered($registration, $form_state['values']['anon_mail'])) {
-    			form_set_error('anon_mail', t('%mail is already registered for this event.',
-    				array('%mail' => $form_state['values']['anon_mail'])));
-    	}
+          form_set_error('anon_mail', t('%mail is already registered for this event.',
+            array('%mail' => $form_state['values']['anon_mail'])));
+      }
       break;
     case REGISTRATION_REGISTRANT_TYPE_ME:
       global $user;
       if (registration_is_registered($registration, NULL, $user->uid)) {
-    			form_set_error('user', t('You are already registered for this event.'));
-    		}
+          form_set_error('user', t('You are already registered for this event.'));
+        }
       break;
     case REGISTRATION_REGISTRANT_TYPE_USER:
       $user = user_load_by_name($form_state['values']['user']);
@@ -190,8 +195,7 @@ function registration_form_submit($form, &$form_state) {
     $form_state['redirect'] = $uri['path'];
   }
   else {
-    drupal_set_message(t('Sorry, there has been a problem submitting your 
-				registration.'));
+    drupal_set_message(t('Sorry, there has been a problem submitting your registration.'));
   }
 }
 
@@ -217,7 +221,7 @@ function registration_delete_confirm($form, &$form_state, $registration) {
   // Always provide entity id in the same form key as in the entity edit form.
   $form['registration'] = array(
     '#type' => 'value',
-		'#value' => $registration,
+    '#value' => $registration,
   );
   return confirm_form($form,
     t('Are you sure you want to delete registration %title?',
@@ -250,7 +254,7 @@ function registration_delete_confirm_submit($form, &$form_state) {
  */
 function registration_registrations_broadcast_form($form, &$form_state, $entity_type, $entity) {
   // we'll need this info when we submit the form
-  list($entity_id, ,) = entity_extract_ids($entity_type, $entity);
+  list($entity_id) = entity_extract_ids($entity_type, $entity);
   $form_state['entity'] = array(
     'entity_id' => $entity_id,
     'entity_type' => $entity_type
@@ -303,7 +307,7 @@ function registration_registrations_broadcast_form_submit($form, &$form_state) {
  * @param object $node
  */
 function registration_registrations_settings_form($form, &$form_state, $entity_type, $entity) {
-  list($entity_id, ,) = entity_extract_ids($entity_type, $entity);
+  list($entity_id) = entity_extract_ids($entity_type, $entity);
   $label = entity_label($entity_type, $entity);
 
   // we'll need this info when we submit the form
@@ -326,10 +330,10 @@ function registration_registrations_settings_form($form, &$form_state, $entity_t
     '#type' => 'textfield',
     '#title' => t('Capacity'),
     '#description' => t('The maximum number of registrants for %name. Leave at 0
-	 			for no limit.', array('%name' => $label)),
+         for no limit.', array('%name' => $label)),
     '#size' => 5,
     '#maxlength' => 10,
-		'#required' => TRUE,
+    '#required' => TRUE,
     '#default_value' => isset($settings['capacity']) ? $settings['capacity'] : 0,
   );
 
@@ -364,82 +368,86 @@ function registration_registrations_settings_form($form, &$form_state, $entity_t
   );
 
 
-	$form['reminder'] = array(
-	  '#type' => 'fieldset',
-	  '#title' => t('Reminder'),
-	  '#collapsible' => TRUE,
-	  '#collapsed' => FALSE,
-	);
-	$form['reminder']['send_reminder'] = array(
-	  '#type' => 'checkbox',
-		'#title' => t('Send Reminder'),
-		'#description' => t('If checked, a reminder will be sent to registrants on the following date.'),
-	  '#default_value' => isset($settings['send_reminder']) ? $settings['send_reminder'] : -1,
-	);
-	
-	$reminder_date = array();
-	if (isset($settings['reminder_date'])) {
-		$datetime = strtotime($settings['reminder_date']);
-		$reminder_date = array(
-			'year' => date('Y', $datetime),
-			'month' => date('n', $datetime),
-			'day' => date('d', $datetime),
-		);		
-	}
-
-	$form['reminder']['reminder_settings'] = array(
-	  '#type' => 'fieldset',
-	  '#title' => t('Settings'),
-	  '#collapsible' => FALSE,
-		'#states' => array(
-		  'visible' => array(
-		    ':input[name="send_reminder"]' => array('checked' => TRUE),
-		  ),
-		)
-	);	
-	$form['reminder']['reminder_settings']['reminder_date'] = array(
-		'#type' => 'date',
-		'#title' => 'Reminder Date',
-	  '#default_value' => $reminder_date,
-	);	
-	$form['reminder']['reminder_settings']['reminder_template'] = array(
-		'#type' => 'textarea',
-		'#title' => 'Template',
-	  '#default_value' => isset($settings['reminder_template']) ? $settings['reminder_template'] : '',
-		'#description' => t('The reminder message sent to registrants. Tokens are supported if the module is enabled, E.g., [node:title].'),
-	);
-	// add token support
-	if (module_exists('token')) {
-	  $form['reminder']['reminder_settings']['token_tree'] = array(
-	    '#theme' => 'token_tree', 
-	    '#token_types' => array('node', 'content-type', 'current-page', 'registration'),
-			'#global_types' => FALSE,
-	  );
-	}
-
-	$form['settings'] = array(
-	  '#type' => 'fieldset',
-	  '#title' => t('Additional Settings'),
-	  '#collapsible' => TRUE,
-	  '#collapsed' => FALSE,
-		'#tree' => TRUE
-	);
-	$form['settings']['multiple_registrations'] = array(
-	  '#type' => 'checkbox',
-	  '#title' => t('Allow multiple registrations'),
-		'#description' => t('If selected, users can register for more than one slot for this event.'),
-	  '#default_value' => isset($settings['settings']['multiple_registrations']) ? $settings['settings']['multiple_registrations'] : -1,
-	);
-	$form['settings']['from_address'] = array(
-	  '#type' => 'textfield',
-	  '#title' => t('From Address'),
-		'#description' => t('From email address to use for confirmations, reminders, and broadcast emails.'),
-		'#required' => TRUE,
-	  '#default_value' => isset($settings['settings']['from_address']) ? 
-				$settings['settings']['from_address'] : 
-				variable_get('site_mail', ini_get('sendmail_from')),
-	);
-	
+  $form['reminder'] = array(
+    '#type' => 'fieldset',
+    '#title' => t('Reminder'),
+    '#collapsible' => TRUE,
+    '#collapsed' => FALSE,
+  );
+
+  $form['reminder']['send_reminder'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Send Reminder'),
+    '#description' => t('If checked, a reminder will be sent to registrants on the following date.'),
+    '#default_value' => isset($settings['send_reminder']) ? $settings['send_reminder'] : -1,
+  );
+
+  $reminder_date = array();
+  if (isset($settings['reminder_date'])) {
+    $datetime = strtotime($settings['reminder_date']);
+    $reminder_date = array(
+      'year' => date('Y', $datetime),
+      'month' => date('n', $datetime),
+      'day' => date('d', $datetime),
+    );
+  }
+
+  $form['reminder']['reminder_settings'] = array(
+    '#type' => 'fieldset',
+    '#title' => t('Settings'),
+    '#collapsible' => FALSE,
+    '#states' => array(
+      'visible' => array(
+        ':input[name="send_reminder"]' => array('checked' => TRUE),
+      ),
+    )
+  );
+
+  $form['reminder']['reminder_settings']['reminder_date'] = array(
+    '#type' => 'date',
+    '#title' => 'Reminder Date',
+    '#default_value' => $reminder_date,
+  );
+
+  $form['reminder']['reminder_settings']['reminder_template'] = array(
+    '#type' => 'textarea',
+    '#title' => 'Template',
+    '#default_value' => isset($settings['reminder_template']) ? $settings['reminder_template'] : '',
+    '#description' => t('The reminder message sent to registrants. Tokens are supported if the module is enabled, E.g., [node:title].'),
+  );
+
+  // add token support
+  if (module_exists('token')) {
+    $form['reminder']['reminder_settings']['token_tree'] = array(
+      '#theme' => 'token_tree',
+      '#token_types' => array('node', 'content-type', 'current-page', 'registration'),
+      '#global_types' => FALSE,
+    );
+  }
+
+  $form['settings'] = array(
+    '#type' => 'fieldset',
+    '#title' => t('Additional Settings'),
+    '#collapsible' => TRUE,
+    '#collapsed' => FALSE,
+    '#tree' => TRUE
+  );
+
+  $form['settings']['multiple_registrations'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Allow multiple registrations'),
+    '#description' => t('If selected, users can register for more than one slot for this event.'),
+    '#default_value' => isset($settings['settings']['multiple_registrations']) ? $settings['settings']['multiple_registrations'] : -1,
+  );
+
+  $form['settings']['from_address'] = array(
+    '#type' => 'textfield',
+    '#title' => t('From Address'),
+    '#description' => t('From email address to use for confirmations, reminders, and broadcast emails.'),
+    '#required' => TRUE,
+    '#default_value' => isset($settings['settings']['from_address']) ? $settings['settings']['from_address'] : variable_get('site_mail', ini_get('sendmail_from')),
+  );
+
   $form['save'] = array(
     '#type' => 'submit',
     '#value' => t('Save Settings'),
@@ -455,16 +463,16 @@ function registration_registrations_settings_form($form, &$form_state, $entity_t
  * @param array $form_state
  */
 function registration_registrations_settings_form_validate($form, &$form_state) {
-	// ensure capacity is a positive integer
-	$capacity = $form_state['values']['capacity'];
-	if (!is_numeric($capacity) || ((int)$capacity != $capacity) || ($capacity < 0)) {
-		form_set_error('capacity', t('Capacity must be a positive integer.'));
-	}
-	
-	// validate from address
-	if (!valid_email_address($form_state['values']['settings']['from_address'])) {
-		form_set_error('settings][from_address', t('From email address is invalid.'));
-	}
+  // ensure capacity is a positive integer
+  $capacity = $form_state['values']['capacity'];
+  if (!is_numeric($capacity) || ((int)$capacity != $capacity) || ($capacity < 0)) {
+    form_set_error('capacity', t('Capacity must be a positive integer.'));
+  }
+
+  // validate from address
+  if (!valid_email_address($form_state['values']['settings']['from_address'])) {
+    form_set_error('settings][from_address', t('From email address is invalid.'));
+  }
 
   // Validate open date
   if (!empty($form_state['values']['scheduling']['open']) && strtotime($form_state['values']['scheduling']['open']) === FALSE) {
@@ -486,17 +494,17 @@ function registration_registrations_settings_form_validate($form, &$form_state)
 function registration_registrations_settings_form_submit($form, &$form_state) {
   $entity = $form_state['entity'];
   $fields = array(
-    'status' => $form_state['values']['status'], 
-    'capacity' => $form_state['values']['capacity'], 
-		'send_reminder' => $form_state['values']['send_reminder'],
-		'settings' => serialize($form_state['values']['settings']),
+    'status' => $form_state['values']['status'],
+    'capacity' => $form_state['values']['capacity'],
+    'send_reminder' => $form_state['values']['send_reminder'],
+    'settings' => serialize($form_state['values']['settings']),
     'open' => NULL,
     'close' => NULL,
   );
-	if ($form_state['values']['send_reminder']) {
-		$fields['reminder_date'] = $form_state['values']['reminder_date']['year'] . '-' . $form_state['values']['reminder_date']['month'] . '-' . $form_state['values']['reminder_date']['day'];
-		$fields['reminder_template'] = $form_state['values']['reminder_template'];
-	}
+  if ($form_state['values']['send_reminder']) {
+    $fields['reminder_date'] = $form_state['values']['reminder_date']['year'] . '-' . $form_state['values']['reminder_date']['month'] . '-' . $form_state['values']['reminder_date']['day'];
+    $fields['reminder_template'] = $form_state['values']['reminder_template'];
+  }
 
   // Scheduling: open date
   if (!empty($form_state['values']['scheduling']['open'])) {
@@ -508,10 +516,9 @@ function registration_registrations_settings_form_submit($form, &$form_state) {
     $fields['close'] = date('Y-m-d H:i:s', strtotime($form_state['values']['scheduling']['close']));
   }
 
-	registration_update_entity_settings($entity['entity_id'], $entity['entity_type'], $fields);
+  registration_update_entity_settings($entity['entity_id'], $entity['entity_type'], $fields);
 
-  $uri = entity_uri($entity['entity_type'],
-      entity_load_single($entity['entity_type'], $entity['entity_id']));
+  $uri = entity_uri($entity['entity_type'], entity_load_single($entity['entity_type'], $entity['entity_id']));
 
   $form_state['redirect'] = $uri['path'];
 }
diff --git a/modules/registration_views/includes/registration_handler_field_entity_capacity_total.inc b/modules/registration_views/includes/registration_handler_field_entity_capacity_total.inc
index 496ebaf..f55a509 100644
--- a/modules/registration_views/includes/registration_handler_field_entity_capacity_total.inc
+++ b/modules/registration_views/includes/registration_handler_field_entity_capacity_total.inc
@@ -1,4 +1,4 @@
-<?php 
+<?php
 /**
  * @file
  * Display maximum slots for an entity.
diff --git a/modules/registration_views/includes/registration_handler_field_entity_capacity_used.inc b/modules/registration_views/includes/registration_handler_field_entity_capacity_used.inc
index 379d2fd..3bb94d1 100644
--- a/modules/registration_views/includes/registration_handler_field_entity_capacity_used.inc
+++ b/modules/registration_views/includes/registration_handler_field_entity_capacity_used.inc
@@ -1,4 +1,4 @@
-<?php 
+<?php
 /**
  * @file
  * Display maximum slots for an entity.
diff --git a/modules/registration_views/includes/registration_handler_field_entity_datetime.inc b/modules/registration_views/includes/registration_handler_field_entity_datetime.inc
index c044362..a8b2925 100644
--- a/modules/registration_views/includes/registration_handler_field_entity_datetime.inc
+++ b/modules/registration_views/includes/registration_handler_field_entity_datetime.inc
@@ -1,8 +1,7 @@
 <?php
-
 /**
  * @file
- * Display registration open or closing dates. 
+ * Display registration open or closing dates.
  */
 class registration_handler_field_entity_datetime extends views_handler_field_date {
   function render($values) {
diff --git a/modules/registration_views/includes/registration_handler_field_entity_registration_status.inc b/modules/registration_views/includes/registration_handler_field_entity_registration_status.inc
index bdbaeaa..fc2f207 100644
--- a/modules/registration_views/includes/registration_handler_field_entity_registration_status.inc
+++ b/modules/registration_views/includes/registration_handler_field_entity_registration_status.inc
@@ -1,4 +1,4 @@
-<?php 
+<?php
 /**
  * @file
  * Display registration status for host entity.
diff --git a/registration.install b/registration.install
index 921f360..bbfcdaf 100644
--- a/registration.install
+++ b/registration.install
@@ -90,9 +90,9 @@ function registration_schema() {
         'columns' => array('user_uid' => 'uid'),
       ),
     ),
-	  'unique keys' => array(
-	    'entity_id_entity_type_user' => array('entity_id', 'entity_type', 'anon_mail', 'user_uid'),
-	  ),
+    'unique keys' => array(
+      'entity_id_entity_type_user' => array('entity_id', 'entity_type', 'anon_mail', 'user_uid'),
+    ),
     'primary key' => array('registration_id'),
   );
 
@@ -124,24 +124,24 @@ function registration_schema() {
         'not null' => TRUE,
         'default' => 1,
       ),
-	    'send_reminder' => array(
-	      'description' => 'Boolean indicating whether reminder emails should be sent. This is set to 0 once the reminders are sent.',
-	      'type' => 'int',
-	      'not null' => TRUE,
-	      'default' => 0,
-	    ),
-	    'reminder_date' => array(
-	      'description' => 'Date to send the reminder on.',
-				'mysql_type' => 'datetime',
-				'pgsql_type' => 'timestamp',
-	      'not null' => FALSE,
-	    ),
-	    'reminder_template' => array(
-	      'description' => 'Reminder email template.',
+      'send_reminder' => array(
+        'description' => 'Boolean indicating whether reminder emails should be sent. This is set to 0 once the reminders are sent.',
+        'type' => 'int',
+        'not null' => TRUE,
+        'default' => 0,
+      ),
+      'reminder_date' => array(
+        'description' => 'Date to send the reminder on.',
+        'mysql_type' => 'datetime',
+        'pgsql_type' => 'timestamp',
+        'not null' => FALSE,
+      ),
+      'reminder_template' => array(
+        'description' => 'Reminder email template.',
         'type' => 'text',
         'size' => 'big',
-	      'not null' => FALSE,
-	    ),
+        'not null' => FALSE,
+      ),
       'open' => array(
         'description' => 'Date to open registrations. Or NULL to open immediately.',
         'mysql_type' => 'datetime',
diff --git a/registration.module b/registration.module
index 7b23fc3..d793777 100644
--- a/registration.module
+++ b/registration.module
@@ -9,8 +9,22 @@ module_load_include('inc', 'registration', 'includes/registration.entity');
 module_load_include('inc', 'registration', 'includes/registration.field');
 module_load_include('inc', 'registration', 'includes/registration.forms');
 
+/**
+ * If user has access to create registrations for his account.
+ * @see registration_access_people()
+ */
 define('REGISTRATION_REGISTRANT_TYPE_ME', 'registration_registrant_type_me');
+
+/**
+ * If user has access to create registrations for other users.
+ * @see registration_access_people()
+ */
 define('REGISTRATION_REGISTRANT_TYPE_USER', 'registration_registrant_type_user');
+
+/**
+ * If user has access to create registrations for people identified by email.
+ * @see registration_access_people()
+ */
 define('REGISTRATION_REGISTRANT_TYPE_ANON', 'registration_registrant_type_anon');
 
 /**
@@ -142,7 +156,7 @@ function registration_permission() {
     ),
   );
 
-  foreach(registration_get_types() as $type_info) {
+  foreach (registration_get_types() as $type_info) {
     $permissions += registration_permission_list($type_info);
   }
 
@@ -152,9 +166,11 @@ function registration_permission() {
 /**
  * Builds permissions for a registration type.
  *
- * @param $registration_type
+ * @param object $info
+ *   Information about a registration type.
+ *
  * @return array
- *   An array of permission names and descriptions.
+ *   An array of permission names and descriptions keyed by permission name.
  */
 function registration_permission_list($info) {
   $type = $info->name;
@@ -198,16 +214,27 @@ function registration_permission_list($info) {
 /**
  * Display a registration.
  *
- * @param  $registration
- *   A Fully loaded registration object.
+ * @param object $registration
+ *   A fully loaded registration object.
  *
- * @return array()
+ * @return array
+ *   Renderable elements.
  */
 function registration_view(Registration $registration) {
   return $registration->view();
 }
+
 /**
- * Page title callback.
+ * Title callback: Generate a title for a registration entity.
+ *
+ * Callback for hook_menu() within system_themes_page().
+ *
+ * @param @registration
+ *   A fully loaded registration object.
+ *
+ * @return string
+ *
+ * @see registration_menu()
  */
 function registration_page_title(Registration $registration) {
   $title = '';
@@ -221,10 +248,23 @@ function registration_page_title(Registration $registration) {
 }
 
 /**
- * Access callback for registration_register_page().
+ * Access callback: for registration_register_page().
+ *
+ * Check if user has access to register for a host entity.
+ *
+ * @param string $entity_type
+ *   The host entity type.
+ * @param object $entity
+ *   The host entity.
+ *
+ * @return bool
+ *   Whether a user can create a new registration for a host entity.
+ *
+ * @see registration_register_page()
+ * @see registration_menu()
  */
 function registration_register_page_access($entity_type, $entity) {
-  list($entity_id, ,) = entity_extract_ids($entity_type, $entity);
+  list($entity_id) = entity_extract_ids($entity_type, $entity);
 
   if ($type = registration_get_entity_registration_type($entity_type, $entity)) {
     $registration = entity_get_controller('registration')->create(array('type' => $type));
@@ -242,7 +282,20 @@ function registration_register_page_access($entity_type, $entity) {
 }
 
 /**
- * Access callback for registration_registrations_page().
+ * Access callback: for registration_registrations_page().
+ *
+ * Check if user has access to administer registrations for a host entity.
+ *
+ * @param string $entity_type
+ *   The host entity type.
+ * @param object $entity
+ *   The host entity.
+ *
+ * @return bool
+ *   Whether a user can view registrations for a host entity.
+ *
+ * @see registration_registrations_page()
+ * @see registration_menu()
  */
 function registration_administer_registrations_access($entity_type, $entity) {
   $registration_type = registration_get_entity_registration_type($entity_type, $entity);
@@ -254,10 +307,21 @@ function registration_administer_registrations_access($entity_type, $entity) {
 }
 
 /**
- * Page callback for adding a registration.
+ * Page callback: Add a new registration to a host entity.
+ *
+ * @param string $entity_type
+ *   The host entity type.
+ * @param object $entity
+ *   The host entity.
+ *
+ * @return array
+ *   A render array
+ *
+ * @see registration_register_access()
+ * @see registration_menu()
  */
 function registration_register_page($entity_type, $entity) {
-  list($entity_id, ,) = entity_extract_ids($entity_type, $entity);
+  list($entity_id) = entity_extract_ids($entity_type, $entity);
   if (registration_status($entity_type, $entity_id)) {
     $registration_type = registration_get_entity_registration_type($entity_type, $entity);
     $registration = entity_get_controller('registration')->create(array('type' => $registration_type));
@@ -273,26 +337,31 @@ function registration_register_page($entity_type, $entity) {
 }
 
 /**
- * Page callback for viewing registrations
+ * Page callback: Show a list of registrations for a host entity.
+ *
+ * @param string $entity_type
+ *   The host entity type.
+ * @param object $entity
+ *   The host entity.
+ *
+ * @return array
+ *   A render array
+ *
+ * @see registration_administer_registrations_access()
+ * @see registration_menu()
  */
 function registration_registrations_page($entity_type, $entity) {
   $header = array(
-    array('data' => t('id'), 'field' => 'registration_id', 'type' => 'property', 
-        'specifier' => 'registration_id'),
-    array('data' => t('Email'), 'field' => 'mail', 'type' => 'property', 
-        'specifier' => 'mail'),
-    array('data' => t('User'), 'field' => 'user_uid', 'type' => 'property',
-        'specifier' => 'user'),
-    array('data' => t('Created By'), 'field' => 'author_uid',
-        'type' => 'property', 'specifier' => 'author_uid'),
-    array('data' => t('Count'), 'field' => 'count', 'type' => 'property', 
-        'specifier' => 'count'),
-    array('data' => t('Created'), 'field' => 'created', 'sort' => 'desc', 
-        'type' => 'property', 'specifier' => 'created'),
+    array('data' => t('id'), 'field' => 'registration_id', 'type' => 'property', 'specifier' => 'registration_id'),
+    array('data' => t('Email'), 'field' => 'mail', 'type' => 'property', 'specifier' => 'mail'),
+    array('data' => t('User'), 'field' => 'user_uid', 'type' => 'property', 'specifier' => 'user'),
+    array('data' => t('Created By'), 'field' => 'author_uid', 'type' => 'property', 'specifier' => 'author_uid'),
+    array('data' => t('Count'), 'field' => 'count', 'type' => 'property',  'specifier' => 'count'),
+    array('data' => t('Created'), 'field' => 'created', 'sort' => 'desc',  'type' => 'property', 'specifier' => 'created'),
     array('data' => t('Actions')),
   );
 
-  list($entity_id, ,) = entity_extract_ids($entity_type, $entity);
+  list($entity_id) = entity_extract_ids($entity_type, $entity);
   $label = entity_label($entity_type, $entity);
 
   $query = new EntityFieldQuery;
@@ -303,7 +372,7 @@ function registration_registrations_page($entity_type, $entity) {
     ->pager(20)
     ->tableSort($header)
     ->execute();
-    
+
   if (!empty($result['registration'])) {
     $registrations = registration_load_multiple(array_keys($result['registration']));
 
@@ -341,24 +410,23 @@ function registration_registrations_page($entity_type, $entity) {
     }
 
     $settings = registration_entity_settings($entity_id, $entity_type);
-        
+
     $table = array(
       'header' => $header,
       'rows' => $rows
     );
     if ($settings['capacity'] != 0) {
-      $table['caption'] = t('List of registrations for %title. !count of !capacity slots are filled.', 
-        array(
-          '%title' => $label,
-          '!count' => '<strong>' . registration_event_count($entity_id, $entity_type) . '</strong>',
-          '!capacity' => '<strong>' . $settings['capacity'] . '</strong>'
-        ));
-    } else {
-      $table['caption'] = t('List of registrations for %title. !count slots are filled.', 
-        array(
-          '%title' => $label,
-          '!count' => '<strong>' . registration_event_count($entity_id, $entity_type) . '</strong>',
-        ));
+      $table['caption'] = t('List of registrations for %title. !count of !capacity slots are filled.', array(
+        '%title' => $label,
+        '!count' => '<strong>' . registration_event_count($entity_id, $entity_type) . '</strong>',
+        '!capacity' => '<strong>' . $settings['capacity'] . '</strong>'
+      ));
+    }
+    else {
+      $table['caption'] = t('List of registrations for %title. !count slots are filled.', array(
+        '%title' => $label,
+        '!count' => '<strong>' . registration_event_count($entity_id, $entity_type) . '</strong>',
+      ));
     }
 
     $out = theme('table', $table) . theme('pager');
@@ -372,67 +440,85 @@ function registration_registrations_page($entity_type, $entity) {
 }
 
 /**
- * Helper to determine if an entity has any slots left.
+ * Determines if a host entity has slots remaining.
  *
- * @param $entity_id
- * @param $entity_type
+ * @param string $entity_type
+ *   The host entity type.
+ * @param int $entity_id
+ *   The host entity ID.
  * @param int $slots
- *   Used if validating a new registration. The number of slots attemping to fill.
+ *   (optional) Used if validating a new registration. The number of slots
+ *   attempting to fill.
+ *
  * @return bool
+ *
+ * @see registration_status()
  */
 function registration_has_room($entity_id, $entity_type, $slots = 0) {
-  $ret      = TRUE;
   $settings = registration_entity_settings($entity_id, $entity_type);
   $capacity = $settings['capacity'];
+
   if ($capacity) {
     $count = registration_event_count($entity_id, $entity_type) + $slots;
     if (($capacity - $count) < 1) {
-      $ret = FALSE;
+      return FALSE;
     }
   }
 
-  return $ret;
+  return TRUE;
 }
 
 /**
- * Return the number of registrations for a given entity.
+ * Determines current number of slots filled for for a host entity.
  *
- * @param int $nid
+ * @param string $entity_type
+ *   The host entity type.
+ * @param int $entity_id
+ *   The host entity ID.
  *
  * @return int
+ *   The number of slots remaining for a host entity.
+ *
+ * @see registration_has_room()
  */
 function registration_event_count($entity_id, $entity_type) {
   $count = &drupal_static(__FUNCTION__ . '_' . $entity_type . '_' . $entity_id, FALSE);
   if (!$count) {
     $count = db_query("SELECT sum(count) FROM {registration} WHERE entity_id = :entity_id AND entity_type = :entity_type",
       array(':entity_id' => $entity_id, ':entity_type' => $entity_type)
-    )->fetchField();    
+    )->fetchField();
   }
   return $count;
 }
 
 /**
  * Implements hook_entity_delete().
- *   Delete registrations and settings for this entity.
+ *
+ * Delete registrations and settings for this host entity.
  */
-function registration_entity_delete($entity, $type) {
+function registration_entity_delete($entity, $entity_type) {
   list($entity_id) = entity_extract_ids($type, $entity);
   db_delete('registration')
     ->condition('entity_id', $entity_id)
-    ->condition('entity_type', $type)
+    ->condition('entity_type', $entity_type)
     ->execute();
   db_delete('registration_entity')
     ->condition('entity_id', $entity_id)
-    ->condition('entity_type', $type)
+    ->condition('entity_type', $entity_type)
     ->execute();
 }
 
+
 /**
- * Return all registration settings for a given entity.
+ * Get registration settings for a host entity.
  *
- * @param string $nid
+ * @param string $entity_type
+ *   The host entity type.
+ * @param int $entity_id
+ *   The host entity ID.
  *
- * @return array
+ * @return array|bool
+ *   A row from {registration_entity}, or FALSE if no settings exist.
  */
 function registration_entity_settings($entity_id, $entity_type) {
   // @TODO: Add static variable handling.
@@ -444,9 +530,9 @@ function registration_entity_settings($entity_id, $entity_type) {
     ->fetchAssoc();
 
   if ($result) {
-    $result['settings'] = unserialize($result['settings']);   
+    $result['settings'] = unserialize($result['settings']);
   }
-  
+
   return $result;
 }
 
@@ -471,7 +557,7 @@ function theme_registration_link($variables) {
   $output = '';
   $registration_label = $variables['label'];
   $registration_path = $variables['path'];
-  
+
   $output .= l($registration_label, $registration_path);
 
   return $output;
@@ -488,9 +574,16 @@ function registration_mail($key, &$message, $params) {
 }
 
 /**
- * Send an email to all registrations for a given entity.
+ * Send an email to all registrations for a host entity.
  *
- * @param object $entity
+ * @param string $entity_type
+ *   The host entity type.
+ * @param int $entity_id
+ *   The host entity ID.
+ * @param string $subject
+ *   Subject of email.
+ * @param string $message
+ *   Message body of email.
  */
 function registration_send_broadcast($entity_type, $entity_id, $subject, $message) {
   global $language;
@@ -548,21 +641,22 @@ function registration_send_broadcast($entity_type, $entity_id, $subject, $messag
   }
   else {
     drupal_set_message(
-      t('There are no participants registered for this %type.', 
-          array('%type' => $entity_type)),
-      $type = 'warning'
+      t('There are no participants registered for this %type.', array('%type' => $entity_type)),
+      'warning'
     );
   }
 }
-
 /**
- * Update an entity's registration settings.
+ * Update or create registration settings for a host entity.
  *
- * @param int $nid 
+ * Updates settings for a host entity, and displays a message to the user.
+ *
+ * @param string $entity_type
+ *   The host entity type.
+ * @param int $entity_id
+ *   The host entity ID.
  * @param array $settings
- *    Associative array containing additional entity registration settings.
- *    Keys are status, capacity, send_reminder, reminder_date, reminder_template
- *    and an associative array of additional settings.
+ *   Array keyed by field names from {registration_entity}
  */
 function registration_update_entity_settings($entity_id, $entity_type, $settings) {
   // insert or update registration entity settings
@@ -574,7 +668,7 @@ function registration_update_entity_settings($entity_id, $entity_type, $settings
     ->fields($settings)
     ->execute();
 
-  drupal_set_message(t('Registration settings have been saved.'));  
+  drupal_set_message(t('Registration settings have been saved.'));
 }
 
 /**
@@ -582,7 +676,7 @@ function registration_update_entity_settings($entity_id, $entity_type, $settings
  */
 function registration_cron() {
   //@TODO: need to have a sensible batch limit, passed in as a limit param
-  
+
   // grab all registrations that have reminders set for this day
   $results = db_select('registration_entity', 're')
     ->fields('re')
@@ -601,7 +695,7 @@ function registration_cron() {
     }
     $subject = 'Reminder for ' . entity_label($result->entity_type, $entity);
     registration_send_broadcast($result->entity_type, $result->entity_id, $subject, $message);
-    
+
     // set reminder flag to off
     db_update('registration_entity')
       ->fields(array('send_reminder' => 0))
@@ -612,17 +706,21 @@ function registration_cron() {
 }
 
 /**
- * Check status of registrations on an entity based on status, open, and close
- * dates, and capacity.
+ * Check if new registrations are permitted for a host entity.
  *
  * Modules may implement hook_registration_status() to alter the status at
  * runtime.
  *
- * @param $entity_type Entity type of entity to check status.
- * @param $entity_id Entity ID of entity to check status.
- * @param $reset Whether to recheck status for the same page session.
+ * @param string $entity_type
+ *   The host entity type.
+ * @param int $entity_id
+ *   The host entity ID.
+ * @param bool $reset
+ *   (optional) Whether to force checking status in case registration_status
+ *   may have been called previously for this host entity.
  *
- * @return Whether new registrations are accepted.
+ * @return bool
+ *   Whether new registrations are accepted.
  */
 function registration_status($entity_type, $entity_id, $reset = FALSE) {
   $checked = &drupal_static(__FUNCTION__, array());
@@ -644,11 +742,11 @@ function registration_status($entity_type, $entity_id, $reset = FALSE) {
       $status = FALSE;
     }
     // check open date range
-    else if (isset($open) && ($now < $open)) {
+    elseif (isset($open) && ($now < $open)) {
       $status = FALSE;
     }
     // check close date range
-    else if (isset($close) && ($now >= $close)) {
+    elseif (isset($close) && ($now >= $close)) {
       $status = FALSE;
     }
   }
@@ -668,33 +766,37 @@ function registration_status($entity_type, $entity_id, $reset = FALSE) {
 }
 
 /**
- * Get the registration type bundle for a given entity.
+ * Get the registration type bundle for a host entity.
  *
  * @param string $entity_type
+ *   The host entity type.
  * @param object $entity
+ *   The host entity.
  *
- * @return string registration type
+ * @return string|bool
+ *   Registration type associated with a host entity, or FALSE if none is
+ *   associated.
  */
 function registration_get_entity_registration_type($entity_type, $entity) {
-  $ret = FALSE;
   $fields = field_read_fields(array('type' => 'registration'));
-  foreach($fields as $field) {
+  foreach ($fields as $field) {
     if (isset($entity->{$field['field_name']})) {
-      $items = field_get_items($entity_type, $entity,$field['field_name']);
+      $items = field_get_items($entity_type, $entity, $field['field_name']);
       // we're assuming there's only a single value in this field
       if (!empty($items) && count($items) == 1) {
-        $ret = $items[0]['registration_type'];
+        return $items[0]['registration_type'];
       }
     }
   }
 
-  return $ret;
+  return FALSE;
 }
 
 /**
  * Return all registration field instances.
- * 
- * @return array list of field instances
+ *
+ * @return array
+ *   A list of field instances
  */
 function registration_get_registration_instances() {
   $registration_fields = field_read_fields(array('type' => 'registration'));
@@ -740,10 +842,19 @@ function registration_tokens($type, $tokens, array $data = array(), array $optio
 }
 
 /**
- * Determine is a given email is already registered for an event.
+ * Determine is a person is registered for a host.
  *
- * @param Registration $registration
- * @param string $mail
+ * A person may be Drupal user account, identified by user uid ($uid).
+ * Or a non-user, identified by an email address ($anon_mail).
+ *
+ * One of $anon_mail or $uid is required.
+ *
+ * @param object $registration
+ *   A fully loaded registration object.
+ * @param string $anon_mail
+ *   (optional) An email address.
+ * @param int $uid
+ *   (optional) A user account uid.
  *
  * @return bool
  */
@@ -755,8 +866,8 @@ function registration_is_registered(Registration $registration, $anon_mail = NUL
   }
 
   $query = db_select('registration', 'r')
-			->condition('entity_id', $registration->entity_id)
-      ->condition('entity_type', $registration->entity_type);
+    ->condition('entity_id', $registration->entity_id)
+    ->condition('entity_type', $registration->entity_type);
 
   if ($anon_mail) {
     // there's a user with this email, check to make sure they're not registered
@@ -767,7 +878,7 @@ function registration_is_registered(Registration $registration, $anon_mail = NUL
       $query->condition('anon_mail', $anon_mail);
     }
   }
-  else if ($uid) {
+  elseif ($uid) {
     $query->condition('user_uid', $uid);
   }
 
@@ -782,14 +893,14 @@ function registration_is_registered(Registration $registration, $anon_mail = NUL
 
 /**
  * Determine people types user may register for an entity.
- * 
- * This will take into account if a user already has a registration for an
+ *
+ * This will take into account if a user already has a registration for a host
  * entity.
- * 
- * @param Registration $registration
- *   A registration entity.
- * @param $account
- *   An account, or omit to get logged in user.
+ *
+ * @param object $registration
+ *   A fully loaded registration object.
+ * @param object $account
+ *   (optional) An user object, or omit for logged in user.
  * @return array
  *   Array keyed with people types, with descriptions.
  */
