diff --git a/includes/MediaBrowserPlugin.inc b/includes/MediaBrowserPlugin.inc
index 1495f43..807a4e4 100644
--- a/includes/MediaBrowserPlugin.inc
+++ b/includes/MediaBrowserPlugin.inc
@@ -20,7 +20,8 @@ abstract class MediaBrowserPlugin implements MediaBrowserPluginInterface {
   protected $info;
 
   /**
-   * The parameters for the current media browser from media_get_browser_params().
+   * The parameters for the current media browser from
+   * media_get_browser_params().
    *
    * @var array
    */
@@ -54,7 +55,8 @@ abstract class MediaBrowserPlugin implements MediaBrowserPluginInterface {
    * This render array will be a jQuery tab in the media browser.
    *
    * Some elements are special:
-   *  - #settings: Drupal.settings.media.browser.$key (where key is the array key).
+   *  - #settings: Drupal.settings.media.browser.$key (where key is the array
+   *    key).
    *  - #callback: If provided, will make the tab an "ajax" tab.
    *  - #title: If provided, will be used as the tab's title. Otherwise the
    *    'title' value from the plugin's hook_media_browser_plugin_info() will
@@ -77,7 +79,7 @@ abstract class MediaBrowserPlugin implements MediaBrowserPluginInterface {
    *   return $build;
    * @endcode
    *
-   * @return
+   * @return array
    *   Renderable array.
    */
   abstract public function view();
diff --git a/includes/MediaBrowserPluginInterface.inc b/includes/MediaBrowserPluginInterface.inc
index 9290f44..3ff1134 100644
--- a/includes/MediaBrowserPluginInterface.inc
+++ b/includes/MediaBrowserPluginInterface.inc
@@ -15,10 +15,10 @@ interface MediaBrowserPluginInterface {
   /**
    * Set up the plugin class.
    *
-   * @param $info
+   * @param array $info
    *   An array of plugin info from hook_media_browser_plugin_info()
    *   implementations.
-   * @param $params
+   * @param array $params
    *   An array of parameters which came in is $_GET['params']. The expected
    *   parameters are still being defined.
    *   - 'types': array of media types to support
@@ -33,11 +33,12 @@ interface MediaBrowserPluginInterface {
    *   An optional user account object from user_load(). Defaults to the current
    *   global user.
    *
-   * @return boolean
+   * @return bool
    *   TRUE if the user can access this plugin, or FALSE otherwise.
    */
   public function access($account = NULL);
 
-  // The view() method is an abstract function so it is defined in MediaBrowserPlugin.
-  // public function view();
+  // The view() method is an abstract function so it is defined in MediaBrowser
+  // Plugin.
+  // @todo public function view();
 }
diff --git a/includes/MediaEntityTranslationHandler.inc b/includes/MediaEntityTranslationHandler.inc
index 2027b80..4e78ed1 100644
--- a/includes/MediaEntityTranslationHandler.inc
+++ b/includes/MediaEntityTranslationHandler.inc
@@ -11,11 +11,16 @@
  */
 class MediaEntityTranslationHandler extends EntityTranslationDefaultHandler {
 
+  /**
+   * Constructor function.
+   */
   public function __construct($entity_type, $entity_info, $entity) {
     parent::__construct('file', $entity_info, $entity);
   }
 
   /**
+   * Entity form handler.
+   *
    * @see EntityTranslationDefaultHandler::entityForm()
    */
   public function entityForm(&$form, &$form_state) {
diff --git a/includes/MediaReadOnlyStreamWrapper.inc b/includes/MediaReadOnlyStreamWrapper.inc
index 2622fbd..ee051fd 100644
--- a/includes/MediaReadOnlyStreamWrapper.inc
+++ b/includes/MediaReadOnlyStreamWrapper.inc
@@ -1,6 +1,11 @@
 <?php
 
 /**
+ * @file
+ * Implements a base class for Resource Stream Wrappers.
+ */
+
+/**
  * A base class for Resource Stream Wrappers.
  *
  * This class provides a complete stream wrapper implementation. It passes
@@ -16,6 +21,9 @@ abstract class MediaReadOnlyStreamWrapper implements DrupalStreamWrapperInterfac
   protected $base_url = NULL;
   private $_DEBUG_MODE = NULL;
 
+  /**
+   * Utility function to return paramenters.
+   */
   public function get_parameters() {
     return $this->parameters;
   }
@@ -27,41 +35,45 @@ abstract class MediaReadOnlyStreamWrapper implements DrupalStreamWrapperInterfac
   const S_IFREG = 0100000;
 
   /**
-   * "Template" for stat calls. All elements must be initialized.
-   * @var array
+   * Template for stat calls.
+   *
+   * All elements must be initialized.
    */
   protected $_stat = array(
-    0 => 0, // device number
+    0 => 0, // Device number
     'dev' => 0,
-    1 => 0, // inode number
+    1 => 0, // Inode number
     'ino' => 0,
-    // inode protection mode. file_unmanaged_delete() requires is_file() to
+    // Inode protection mode. file_unmanaged_delete() requires is_file() to
     // return TRUE.
     2 => self::S_IFREG,
     'mode' => self::S_IFREG,
-    3 => 0, // number of links
+    3 => 0, // Number of links.
     'nlink' => 0,
-    4 => 0, // userid of owner
+    4 => 0, // Userid of owner.
     'uid' => 0,
-    5 => 0, // groupid of owner
+    5 => 0, // Groupid of owner.
     'gid' => 0,
-    6 => -1, // device type, if inode device *
+    6 => -1, // Device type, if inode device *
     'rdev' => -1,
-    7 => 0, // size in bytes
+    7 => 0, // Size in bytes.
     'size' => 0,
-    8 => 0, // time of last access (Unix timestamp)
+    8 => 0, // Time of last access (Unix timestamp).
     'atime' => 0,
-    9 => 0, // time of last modification (Unix timestamp)
+    9 => 0, // Time of last modification (Unix timestamp).
     'mtime' => 0,
-    10 => 0, // time of last inode change (Unix timestamp)
+    10 => 0, // Time of last inode change (Unix timestamp).
     'ctime' => 0,
-    11 => -1, // blocksize of filesystem IO
+    11 => -1, // Blocksize of filesystem IO.
     'blksize' => -1,
-    12 => -1, // number of blocks allocated
+    12 => -1, // Number of blocks allocated.
     'blocks' => -1,
   );
 
-  function interpolateUrl() {
+  /**
+   * Handles parameters on the URL string.
+   */
+  public function interpolateUrl() {
     if ($parameters = $this->get_parameters()) {
       return $this->base_url . '?' . http_build_query($parameters);
     }
@@ -75,7 +87,7 @@ abstract class MediaReadOnlyStreamWrapper implements DrupalStreamWrapperInterfac
    * "youtube://xIpLd0WQKCY" might be
    * "http://www.youtube.com/watch?v=xIpLd0WQKCY".
    *
-   * @return
+   * @return string
    *   Returns a string containing a web accessible URL for the resource.
    */
   public function getExternalUrl() {
@@ -85,18 +97,18 @@ abstract class MediaReadOnlyStreamWrapper implements DrupalStreamWrapperInterfac
   /**
    * Base implementation of getMimeType().
    */
-  static function getMimeType($uri, $mapping = NULL) {
+  public static function getMimeType($uri, $mapping = NULL) {
     return 'application/octet-stream';
   }
 
   /**
    * Base implementation of realpath().
    */
-  function realpath() {
+  public function realpath() {
     return $this->getExternalUrl();
   }
 
-   /**
+  /**
    * Stream context resource.
    *
    * @var Resource
@@ -122,7 +134,7 @@ abstract class MediaReadOnlyStreamWrapper implements DrupalStreamWrapperInterfac
   /**
    * Base implementation of setUri().
    */
-  function setUri($uri) {
+  public function setUri($uri) {
     $this->uri = $uri;
     $this->parameters = $this->_parse_url($uri);
   }
@@ -130,21 +142,23 @@ abstract class MediaReadOnlyStreamWrapper implements DrupalStreamWrapperInterfac
   /**
    * Base implementation of getUri().
    */
-  function getUri() {
+  public function getUri() {
     return $this->uri;
   }
 
   /**
-   *  Report an error.
-   *  @param $message
-   *    The untranslated string to report.
-   *  @param $options
-   *    An optional array of options to send to t().
-   *  @param $display
-   *    If TRUE, then we display the error to the user.
-   *  @return
-   *    We return FALSE, since we sometimes pass that back from the reporting
-   *    function.
+   * Report an error.
+   *
+   * @param string $message
+   *   The untranslated string to report.
+   * @param array $options
+   *   An optional array of options to send to t().
+   * @param bool $display
+   *   If TRUE, then we display the error to the user.
+   *
+   * @return bool
+   *   We return FALSE, since we sometimes pass that back from the reporting
+   *   function.
    */
   private function _report_error($message, $options = array(), $display = FALSE) {
     watchdog('resource', $message, $options, WATCHDOG_ERROR);
@@ -154,6 +168,9 @@ abstract class MediaReadOnlyStreamWrapper implements DrupalStreamWrapperInterfac
     return FALSE;
   }
 
+  /**
+   * Sets the debug mode.
+   */
   private function _debug($message, $type = 'status') {
     if ($this->_DEBUG_MODE) {
       drupal_set_message($message, $type);
@@ -161,16 +178,18 @@ abstract class MediaReadOnlyStreamWrapper implements DrupalStreamWrapperInterfac
   }
 
   /**
-   *  Returns an array of any parameters stored in the URL's path.
-   *  @param $url
-   *    The URL to parse, such as youtube://v/[video-code]/t/[tags+more-tags].
-   *  @return
-   *    An associative array of all the parameters in the path,
-   *    or FALSE if the $url is ill-formed.
+   * Returns an array of any parameters stored in the URL's path.
+   *
+   * @param string $url
+   *   The URL to parse, such as youtube://v/[video-code]/t/[tags+more-tags].
+   *
+   * @return array
+   *   An associative array of all the parameters in the path,
+   *   or FALSE if the $url is ill-formed.
    */
   protected function _parse_url($url) {
     $path = explode('://', $url);
-    $parts = explode('/',  $path[1]);
+    $parts = explode('/', $path[1]);
     $params = array();
     $count = 0;
     $total = count($parts);
@@ -188,16 +207,17 @@ abstract class MediaReadOnlyStreamWrapper implements DrupalStreamWrapperInterfac
   /**
    * Support for fopen(), file_get_contents(), file_put_contents() etc.
    *
-   * @param $path
+   * @param string $url
    *   A string containing the path to the file to open.
-   * @param $mode
+   * @param string $mode
    *   The file mode ("r", "wb" etc.).
-   * @param $options
+   * @param bitmask $options
    *   A bit mask of STREAM_USE_PATH and STREAM_REPORT_ERRORS.
-   * @param &$opened_path
+   * @param string &$opened_url
    *   A string containing the path actually opened.
-   * @return
-   *  TRUE if file was opened successfully.
+   *
+   * @return bool
+   *   TRUE if file was opened successfully.
    */
   public function stream_open($url, $mode, $options, &$opened_url) {
     $this->_debug(t('Stream open: %url', array('%url' => $url)));
@@ -215,16 +235,18 @@ abstract class MediaReadOnlyStreamWrapper implements DrupalStreamWrapperInterfac
       return $this->_report_error('Attempted to parse an ill-formed url: %url.', array('%url' => $url), ($options & STREAM_REPORT_ERRORS));
     }
 
-    if ((bool)$this->parameters && ($options & STREAM_USE_PATH)) {
+    if ((bool) $this->parameters && ($options & STREAM_USE_PATH)) {
       $opened_url = $url;
     }
 
     $this->_debug(t('Stream opened: %parameters', array('%parameters' => print_r($this->parameters, TRUE))));
 
-    return (bool)$this->parameters;
+    return (bool) $this->parameters;
   }
 
-  // Undocumented PHP stream wrapper method.
+  /**
+   * Undocumented PHP stream wrapper method.
+   */
   function stream_lock($operation) {
     return FALSE;
   }
@@ -232,10 +254,11 @@ abstract class MediaReadOnlyStreamWrapper implements DrupalStreamWrapperInterfac
   /**
    * Support for fread(), file_get_contents() etc.
    *
-   * @param $count
-   *    Maximum number of bytes to be read.
-   * @return
-   *  The string that was read, or FALSE in case of an error.
+   * @param int $count
+   *   Maximum number of bytes to be read.
+   *
+   * @return bool
+   *   The string that was read, or FALSE in case of an error.
    */
   public function stream_read($count) {
     return FALSE;
@@ -244,10 +267,13 @@ abstract class MediaReadOnlyStreamWrapper implements DrupalStreamWrapperInterfac
   /**
    * Support for fwrite(), file_put_contents() etc.
    *
-   * @param $data
+   * Since this is a read only stream wrapper this always returns false.
+   *
+   * @param string $data
    *   The string to be written.
-   * @return
-   *   The number of bytes written.
+   *
+   * @return bool
+   *   Returns FALSE.
    */
   public function stream_write($data) {
     return FALSE;
@@ -256,7 +282,7 @@ abstract class MediaReadOnlyStreamWrapper implements DrupalStreamWrapperInterfac
   /**
    * Support for feof().
    *
-   * @return
+   * @return bool
    *   TRUE if end-of-file has been reached.
    */
   public function stream_eof() {
@@ -266,11 +292,14 @@ abstract class MediaReadOnlyStreamWrapper implements DrupalStreamWrapperInterfac
   /**
    * Support for fseek().
    *
-   * @param $offset
+   * @todo document why this returns false.
+   *
+   * @param int $offset
    *   The byte offset to got to.
-   * @param $whence
+   * @param string $whence
    *   SEEK_SET, SEEK_CUR, or SEEK_END.
-   * @return
+   *
+   * @return bool
    *   TRUE on success
    */
   public function stream_seek($offset, $whence) {
@@ -280,7 +309,9 @@ abstract class MediaReadOnlyStreamWrapper implements DrupalStreamWrapperInterfac
   /**
    * Support for fflush().
    *
-   * @return
+   * @todo document why this returns false.
+   *
+   * @return bool
    *   TRUE if data was successfully stored (or there was no data to store).
    */
   public function stream_flush() {
@@ -290,7 +321,9 @@ abstract class MediaReadOnlyStreamWrapper implements DrupalStreamWrapperInterfac
   /**
    * Support for ftell().
    *
-   * @return
+   * @todo document why this returns false.
+   *
+   * @return bool
    *   The current offset in bytes from the beginning of file.
    */
   public function stream_tell() {
@@ -300,7 +333,7 @@ abstract class MediaReadOnlyStreamWrapper implements DrupalStreamWrapperInterfac
   /**
    * Support for fstat().
    *
-   * @return
+   * @return array
    *   An array with file status, or FALSE in case of an error - see fstat()
    *   for a description of this array.
    */
@@ -311,104 +344,24 @@ abstract class MediaReadOnlyStreamWrapper implements DrupalStreamWrapperInterfac
   /**
    * Support for fclose().
    *
-   * @return
+   * @todo document why this returns TRUE.
+   *
+   * @return bool
    *   TRUE if stream was successfully closed.
    */
   public function stream_close() {
     return TRUE;
   }
 
-
-  /**
-   * Support for unlink().
-   *
-   * @param $uri
-   *   A string containing the uri to the resource to delete.
-   * @return
-   *   TRUE if resource was successfully deleted.
-   * @see http://php.net/manual/en/streamwrapper.unlink.php
-   */
-//   public function unlink($uri) {
-//     $this->uri = $uri;
-//     return unlink($this->getLocalPath());
-//   }
-
-  /**
-   * Support for rename().
-   *
-   * @param $from_uri,
-   *   The uri to the file to rename.
-   * @param $to_uri
-   *   The new uri for file.
-   * @return
-   *   TRUE if file was successfully renamed.
-   * @see http://php.net/manual/en/streamwrapper.rename.php
-   */
-//   public function rename($from_uri, $to_uri) {
-//     return rename($this->getLocalPath($from_uri), $this->getLocalPath($to_uri));
-//   }
-
-  /**
-   * Support for mkdir().
-   *
-   * @param $uri
-   *   A string containing the URI to the directory to create.
-   * @param $mode
-   *   Permission flags - see mkdir().
-   * @param $options
-   *   A bit mask of STREAM_REPORT_ERRORS and STREAM_MKDIR_RECURSIVE.
-   * @return
-   *   TRUE if directory was successfully created.
-   * @see http://php.net/manual/en/streamwrapper.mkdir.php
-   */
-//   public function mkdir($uri, $mode, $options) {
-//     $this->uri = $uri;
-//     $recursive = (bool)($options & STREAM_MKDIR_RECURSIVE);
-//     if ($recursive) {
-//       // $this->getLocalPath() fails if $uri has multiple levels of directories
-//       // that do not yet exist.
-//       $localpath = $this->getDirectoryPath() . '/' . file_uri_target($uri);
-//     }
-//     else {
-//       $localpath = $this->getLocalPath($uri);
-//     }
-//     if ($options & STREAM_REPORT_ERRORS) {
-//       return mkdir($localpath, $mode, $recursive);
-//     }
-//     else {
-//       return @mkdir($localpath, $mode, $recursive);
-//     }
-//   }
-
-  /**
-   * Support for rmdir().
-   *
-   * @param $uri
-   *   A string containing the URI to the directory to delete.
-   * @param $options
-   *   A bit mask of STREAM_REPORT_ERRORS.
-   * @return
-   *   TRUE if directory was successfully removed.
-   * @see http://php.net/manual/en/streamwrapper.rmdir.php
-   */
-//   public function rmdir($uri, $options) {
-//     $this->uri = $uri;
-//     if ($options & STREAM_REPORT_ERRORS) {
-//       return rmdir($this->getLocalPath());
-//     }
-//     else {
-//       return @rmdir($this->getLocalPath());
-//     }
-//   }
-
   /**
    * Support for stat().
    *
-   * @param $url
+   * @param string $url
    *   A string containing the url to get information about.
-   * @param $flags
+   * @param bitmask $flags
    *   A bit mask of STREAM_URL_STAT_LINK and STREAM_URL_STAT_QUIET.
-   * @return
+   *
+   * @return array
    *   An array with file status, or FALSE in case of an error - see fstat()
    *   for a description of this array.
    */
@@ -419,11 +372,12 @@ abstract class MediaReadOnlyStreamWrapper implements DrupalStreamWrapperInterfac
   /**
    * Support for opendir().
    *
-   * @param $url
+   * @param string $url
    *   A string containing the url to the directory to open.
-   * @param $options
-   *   Unknown (parameter is not documented in PHP Manual).
-   * @return
+   * @param int $options
+   *   Whether or not to enforce safe_mode (0x04).
+   *
+   * @return bool
    *   TRUE on success.
    */
   public function dir_opendir($url, $options) {
@@ -433,7 +387,7 @@ abstract class MediaReadOnlyStreamWrapper implements DrupalStreamWrapperInterfac
   /**
    * Support for readdir().
    *
-   * @return
+   * @return bool
    *   The next filename, or FALSE if there are no more files in the directory.
    */
   public function dir_readdir() {
@@ -443,7 +397,7 @@ abstract class MediaReadOnlyStreamWrapper implements DrupalStreamWrapperInterfac
   /**
    * Support for rewinddir().
    *
-   * @return
+   * @return bool
    *   TRUE on success.
    */
   public function dir_rewinddir() {
@@ -453,13 +407,18 @@ abstract class MediaReadOnlyStreamWrapper implements DrupalStreamWrapperInterfac
   /**
    * Support for closedir().
    *
-   * @return
+   * @return bool
    *   TRUE on success.
    */
   public function dir_closedir() {
     return FALSE;
   }
 
+  /**
+   * Undocumented.
+   *
+   * @todo document.
+   */
   public function getDirectoryPath() {
     return '';
   }
@@ -470,23 +429,46 @@ abstract class MediaReadOnlyStreamWrapper implements DrupalStreamWrapperInterfac
    * are expected to return FALSE.
    */
 
+  /**
+   * Implements DrupalStreamWrapperInterface::unlink().
+   */
   public function unlink($uri) {
     // Although the remote file itself can't be deleted, return TRUE so that
-    // file_delete() can remove the file record from the database.
+    // file_delete() can remove the file record from the Drupal database.
     return TRUE;
   }
+
+  /**
+   * Implements DrupalStreamWrapperInterface::rename().
+   */
   public function rename($from_uri, $to_uri) {
     return FALSE;
   }
+
+  /**
+   * Implements DrupalStreamWrapperInterface::mkdir().
+   */
   public function mkdir($uri, $mode, $options) {
     return FALSE;
   }
+
+  /**
+   * Implements DrupalStreamWrapperInterface::rmdir().
+   */
   public function rmdir($uri, $options) {
     return FALSE;
   }
+
+  /**
+   * Implements DrupalStreamWrapperInterface::chmod().
+   */
   public function chmod($mode) {
     return FALSE;
   }
+
+  /**
+   * Implements DrupalStreamWrapperInterface::dirname().
+   */
   public function dirname($uri = NULL) {
     return FALSE;
   }
diff --git a/includes/media.admin.inc b/includes/media.admin.inc
index 2e9c259..88b88b9 100644
--- a/includes/media.admin.inc
+++ b/includes/media.admin.inc
@@ -32,7 +32,7 @@ function media_import($form, &$form_state) {
     $form['actions'] = array('#type' => 'actions');
     $form['actions']['submit'] = array(
       '#type' => 'submit',
-      '#value' => t('Preview')
+      '#value' => t('Preview'),
     );
     $form['actions']['cancel'] = array(
       '#type' => 'link',
@@ -61,7 +61,7 @@ function media_import_validate($form, &$form_state) {
     if (!is_dir($directory)) {
       form_set_error('directory', t('The provided directory does not exist.'));
     }
-    $pattern = !empty($pattern) ? $pattern :  '*';
+    $pattern = !empty($pattern) ? $pattern : '*';
     $files = glob("$directory/$pattern");
     if (empty($files)) {
       form_set_error('pattern', t('No files were found in %directory matching %pattern', array('%directory' => $directory, '%pattern' => $pattern)));
@@ -126,10 +126,10 @@ function media_import_batch_import_files($files, &$context) {
   }
 
   $context['message'] = "Importing " . theme('item_list', array('items' => $to_process));
-  $context['message'] .= drupal_render($image_in_message); // Just for kicks, show an image we are importing
+  // Show the image that is being imported.
+  $context['message'] .= drupal_render($image_in_message);
 
   $context['finished'] = ($context['sandbox']['max'] - count($files)) / $context['sandbox']['max'];
-
 }
 
 /**
@@ -160,7 +160,9 @@ function media_admin_config_browser($form, &$form_state) {
     '#type' => 'select',
     '#title' => t('Media browser theme'),
     '#options' => $theme_options,
-    '#description' => t("This theme will be used for all media related dialogs.  It can be different from your site's theme because many site themes do not work well in the small windows which media uses."),
+    '#description' => t("This theme will be used for all media related dialogs.
+      It can be different from your site's theme because many site themes do not
+      work well in the small windows which media uses."),
     '#default_value' => media_variable_get('dialog_theme'),
   );
 
@@ -168,7 +170,11 @@ function media_admin_config_browser($form, &$form_state) {
     '#type' => 'textfield',
     '#title' => t('Allowed file extensions'),
     '#default_value' => media_variable_get('file_extensions'),
-    '#description' => t('File extensions which are accepted in the media browser.  Use spaces to separate (e.g. "jpg gif pdf doc"). <br/><em>Note that this can be overriden on a per-field basis when creating multimedia asset fields and files of certain extensions cannot be embedded at this time.</em>'),
+    '#description' => t('File extensions which are accepted in the media
+      browser. Use spaces to separate (for example: "jpg gif pdf doc").
+      <br/><em>Note that this can be overriden on a per-field basis when
+      creating multimedia asset fields and files of certain extensions cannot be
+      embedded at this time.</em>'),
     '#maxlength' => 255,
   );
 
@@ -219,6 +225,9 @@ function media_admin_config_browser($form, &$form_state) {
   return system_settings_form($form);
 }
 
+/**
+ * Manipulate values before form is submitted.
+ */
 function media_admin_config_browser_pre_submit(&$form, &$form_state) {
   if (!$form_state['values'][media_variable_name('dialog_theme')]) {
     media_variable_del('dialog_theme');
diff --git a/includes/media.browser.inc b/includes/media.browser.inc
index fb13c65..36ee0b0 100644
--- a/includes/media.browser.inc
+++ b/includes/media.browser.inc
@@ -33,7 +33,8 @@ function media_browser($selected = NULL) {
 
   $plugins = media_get_browser_plugin_info();
 
-  // Allow parameters to provide a list of enabled or disabled media browser plugins.
+  // Allow parameters to provide a list of enabled or disabled media browser
+  // plugins.
   if (!empty($params['enabledPlugins'])) {
     $plugins = array_intersect_key($plugins, array_fill_keys($params['enabledPlugins'], 1));
   }
@@ -81,8 +82,16 @@ function media_browser($selected = NULL) {
     // This is a fairly broad assumption.
     if (empty($plugin_output[$key]['#form']) && !empty($plugin_output[$key]['#markup'])) {
       $fake_buttons = '<div class="form-actions form-wrapper">';
-      $fake_buttons .= l(t('Submit'), '', array('attributes' => array('class' => array('button', 'button-yes', 'fake-submit', $key))));
-      $fake_buttons .= l(t('Cancel'), '', array('attributes' => array('class' => array('button', 'button-no', 'fake-cancel', $key))));
+      $fake_buttons .= l(t('Submit'), '', array(
+        'attributes' => array(
+          'class' => array('button', 'button-yes', 'fake-submit', $key),
+        ),
+      ));
+      $fake_buttons .= l(t('Cancel'), '', array(
+        'attributes' => array(
+          'class' => array('button', 'button-no', 'fake-cancel', $key),
+        ),
+      ));
       $fake_buttons .= '</div>';
       $plugin_output[$key]['#markup'] .= $fake_buttons;
     }
@@ -95,7 +104,14 @@ function media_browser($selected = NULL) {
         '#type' => 'link',
         '#title' => t('Cancel'),
         '#href' => '',
-        '#attributes' => array('class' => array('button', 'button-no', 'fake-cancel', $key)),
+        '#attributes' => array(
+          'class' => array(
+            'button',
+            'button-no',
+            'fake-cancel',
+            $key,
+          ),
+        ),
         '#weight' => 100,
       );
     }
@@ -106,7 +122,7 @@ function media_browser($selected = NULL) {
   // that we should write to be making the tabs.
   drupal_alter('media_browser_plugins', $plugin_output);
 
-  $tabs = array(); // List of tabs to render.
+  $tabs = array();
   $settings = array('media' => array('browser' => array()));
 
   foreach (element_children($plugin_output, TRUE) as $key) {
@@ -157,32 +173,36 @@ function media_browser($selected = NULL) {
  *
  * @see media_browser()
  */
- function media_set_browser_params() {
-   $params = &drupal_static(__FUNCTION__, array());
-
-   if (empty($params)) {
-     // Build out browser settings. Permissions- and security-related behaviors
-     // should not rely on these parameters, since they come from the HTTP query.
-     // @TODO make sure we treat parameters as user input.
-     $params = drupal_get_query_parameters() + array(
-       'types' => array(),
-       'multiselect' => FALSE,
-     );
-
-     // Transform text 'true' and 'false' to actual booleans.
-     foreach ($params as $k => $v) {
-       if ($v === 'true') { $params[$k] = TRUE; }
-       elseif ($v === 'false') { $params[$k] = FALSE; }
-     }
+function media_set_browser_params() {
+  $params = &drupal_static(__FUNCTION__, array());
+
+  if (empty($params)) {
+    // Build out browser settings. Permissions- and security-related behaviors
+    // should not rely on these parameters, since they come from the HTTP query.
+    // @TODO make sure we treat parameters as user input.
+    $params = drupal_get_query_parameters() + array(
+      'types' => array(),
+      'multiselect' => FALSE,
+    );
+
+    // Transform text 'true' and 'false' to actual booleans.
+    foreach ($params as $k => $v) {
+      if ($v === 'true') {
+        $params[$k] = TRUE;
+      }
+      elseif ($v === 'false') {
+        $params[$k] = FALSE;
+      }
+    }
 
-     array_walk_recursive($params, 'media_recursive_check_plain');
+    array_walk_recursive($params, 'media_recursive_check_plain');
 
-     // Allow modules to alter the parameters.
-     drupal_alter('media_browser_params', $params);
-   }
+    // Allow modules to alter the parameters.
+    drupal_alter('media_browser_params', $params);
+  }
 
-   return $params;
- }
+  return $params;
+}
 
 
 /**
@@ -197,8 +217,8 @@ function media_get_browser_params() {
 /**
  * Attaches media browser javascript to an element.
  *
- * @param $element
- *  The element array to attach to.
+ * @param array $element
+ *   The element array to attach to.
  */
 function media_attach_browser_js(&$element) {
   $javascript = media_browser_js();
@@ -214,10 +234,14 @@ function media_attach_browser_js(&$element) {
  */
 function media_browser_js() {
   $settings = array(
-    'browserUrl' => url('media/browser',
-      array('query' => array('render' => 'media-popup'))),
-    'styleSelectorUrl' => url('media/-media_id-/format-form',
-      array('query' => array('render' => 'media-popup'))),
+    'browserUrl' => url('media/browser', array(
+        'query' => array('render' => 'media-popup'),
+      )
+    ),
+    'styleSelectorUrl' => url('media/-media_id-/format-form', array(
+        'query' => array('render' => 'media-popup'),
+      )
+    ),
   );
 
   $js = array(
@@ -226,8 +250,8 @@ function media_browser_js() {
     ),
     'js' => array(
       array(
-       'data' => array('media' => $settings),
-       'type' => 'setting',
+        'data' => array('media' => $settings),
+        'type' => 'setting',
       ),
     ),
   );
@@ -235,7 +259,7 @@ function media_browser_js() {
 }
 
 /**
- * Menu callback for testing the media browser
+ * Menu callback for testing the media browser.
  */
 function media_browser_testbed($form) {
   media_attach_browser_js($form);
@@ -246,7 +270,7 @@ function media_browser_testbed($form) {
       'global' => array(
         'types' => array('video', 'audio'),
       ),
-    )
+    ),
   );
 
   $launcher = '<a href="#" id="launcher"> Launch Media Browser</a>';
@@ -266,7 +290,6 @@ function media_browser_testbed($form) {
     '#title' => 'Result',
   );
 
-
   $js = <<<EOF
     Drupal.behaviors.mediaTest = {
     attach: function(context, settings) {
@@ -317,7 +340,9 @@ EOF;
 }
 
 /**
- * Adds properties to the passed in file that are needed by the media browser JS code.
+ * Adds properties to the file.
+ *
+ * Additional properties on this file are needed by the media browser JS code.
  */
 function media_browser_build_media_item($file) {
   $preview = media_get_thumbnail_preview($file);
diff --git a/includes/media.fields.inc b/includes/media.fields.inc
index 75f98e1..35692ed 100644
--- a/includes/media.fields.inc
+++ b/includes/media.fields.inc
@@ -142,7 +142,9 @@ function media_field_widget_form(&$form, &$form_state, $field, $instance, $langc
   }
 
   $element += array(
-    '#type' => 'media', // Would like to make this a fieldset, but throws some weird warning about element_children... not sure what it is about yet.
+    // @todo This should be a fieldset, but throws a warning about
+    // element_children.
+    '#type' => 'media',
     '#collapsed' => TRUE,
     '#default_value' => $current_value,
     '#required' => $instance['required'],
@@ -178,6 +180,8 @@ function media_field_widget_form(&$form, &$form_state, $field, $instance, $langc
 }
 
 /**
+ * Widget value.
+ *
  * @todo Is this function ever called? If not, remove it. The Field API now
  *   supports automatic serialization / unserialization, so this should no
  *   longer be needed. After verifying with a module that uses the 'data'
diff --git a/includes/media.filter.inc b/includes/media.filter.inc
index b8f8065..4cc5a4e 100644
--- a/includes/media.filter.inc
+++ b/includes/media.filter.inc
@@ -14,15 +14,15 @@ function media_wysiwyg_include_directory($type) {
   switch ($type) {
     case 'plugins':
       return 'wysiwyg_plugins';
-        break;
-    }
+
+    break;
+  }
 }
 
 /**
  * Filter callback for media markup filter.
  *
  * @TODO check for security probably pass text through filter_xss
- * @return unknown_type
  */
 function media_filter($text) {
   $text = ' ' . $text . ' ';
@@ -32,15 +32,15 @@ function media_filter($text) {
 }
 
 /**
- * Parses the contents of a CSS declaration block and returns a keyed array of property names and values.
+ * Parses the contents of a CSS declaration block.
  *
- * @param $declarations
+ * @param string $declarations
  *   One or more CSS declarations delimited by a semicolon. The same as a CSS
  *   declaration block (see http://www.w3.org/TR/CSS21/syndata.html#rule-sets),
  *   but without the opening and closing curly braces. Also the same as the
  *   value of an inline HTML style attribute.
  *
- * @return
+ * @return array
  *   A keyed array. The keys are CSS property names, and the values are CSS
  *   property values.
  */
@@ -60,9 +60,10 @@ function media_parse_css_declarations($declarations) {
  *
  * @param string $match
  *   Takes a match of tag code
- * @param boolean $wysiwyg
+ * @param bool $wysiwyg
  *   Set to TRUE if called from within the WYSIWYG text area editor.
- * @return
+ *
+ * @return string
  *   The HTML markup representation of the tag, or an empty string on failure.
  *
  * @see media_get_file_without_label()
@@ -111,7 +112,6 @@ function media_token_to_markup($match, $wysiwyg = FALSE) {
       }
     }
 
-
     $file = file_load($tag_info['fid']);
     if (!$file) {
       throw new Exception('Could not load media object');
@@ -139,7 +139,7 @@ function media_token_to_markup($match, $wysiwyg = FALSE) {
       // of the style attribute or the corresponding HTML attributes, so pull
       // these two out into top-level settings. Different WYSIWYG editors have
       // different behavior with respect to whether they store user-specified
-      // dimensions in the HTML attributes or the style attribute, so check both.
+      // dimensions in the HTML attributes or the style attribute- check both.
       // Per http://www.w3.org/TR/html5/the-map-element.html#attr-dim-width, the
       // HTML attributes are merely hints: CSS takes precedence.
       if (isset($settings['attributes']['style'])) {
@@ -180,11 +180,13 @@ function media_token_to_markup($match, $wysiwyg = FALSE) {
     // Display the field elements.
     $element = array();
     $element['content']['file'] = media_get_file_without_label($file, $tag_info['view_mode'], $settings);
-    // Overwrite or set the file #alt attribute if it has been set in this instance.
+    // Overwrite or set the file #alt attribute if it has been set in this
+    // instance.
     if (!empty($element['content']['file']['#attributes']['alt'])) {
       $element['content']['file']['#alt'] = $element['content']['file']['#attributes']['alt'];
     }
-    // Overwrite or set the file #title attribute if it has been set in this instance.
+    // Overwrite or set the file #title attribute if it has been set in this
+    // instance.
     if (!empty($element['content']['file']['#attributes']['title'])) {
       $element['content']['file']['#title'] = $element['content']['file']['#attributes']['title'];
     }
@@ -211,11 +213,11 @@ function media_token_to_markup($match, $wysiwyg = FALSE) {
 }
 
 /**
- * Builds a map of media tags in the element being rendered to their rendered HTML.
+ * Builds a map of media tags in the element.
  *
- * The map is stored in JS, so we can transform them when the editor is being displayed.
- *
- * @param array $element
+ * Builds a map of the media tags in an element that are being rendered to their
+ * rendered HTML. The map is stored in JS, so we can transform them when the
+ * editor is being displayed.
  */
 function media_pre_render_text_format($element) {
   // filter_process_format() copies properties to the expanded 'value' child
@@ -238,12 +240,16 @@ function media_pre_render_text_format($element) {
 }
 
 /**
+ * Creates map of inline media tags.
+ *
  * Generates an array of [inline tags] => <html> to be used in filter
  * replacement and to add the mapping to JS.
- * @param
- * The String containing text and html markup of textarea
- * @return
- * An associative array with tag code as key and html markup as the value.
+ *
+ * @param string $text
+ *   The String containing text and html markup of textarea
+ *
+ * @return array
+ *   An associative array with tag code as key and html markup as the value.
  *
  * @see media_process_form()
  * @see media_token_to_markup()
@@ -336,7 +342,8 @@ function media_format_form($form, $form_state, $file) {
   $view_modes = media_get_wysiwyg_allowed_view_modes($file);
   $formats = $options = array();
   foreach ($view_modes as $view_mode => $view_mode_info) {
-    //@TODO: Display more verbose information about which formatter and what it does.
+    // @TODO: Display more verbose information about which formatter and what it
+    // does.
     $options[$view_mode] = $view_mode_info['label'];
     $element = media_get_file_without_label($file, $view_mode, array('wysiwyg' => TRUE));
 
@@ -382,7 +389,7 @@ function media_format_form($form, $form_state, $file) {
     '#markup' => drupal_render($preview),
   );
 
-  // These will get passed on to WYSIWYG
+  // These will get passed on to WYSIWYG.
   $form['options'] = array(
     '#type' => 'fieldset',
     '#title' => t('options'),
@@ -392,7 +399,7 @@ function media_format_form($form, $form_state, $file) {
     '#type' => 'select',
     '#title' => t('Current format is'),
     '#options' => $options,
-    '#default_value' => $default_view_mode
+    '#default_value' => $default_view_mode,
   );
 
   if ($file->type === 'image') {
@@ -411,11 +418,11 @@ function media_format_form($form, $form_state, $file) {
     );
   }
 
-  // Similar to a form_alter, but we want this to run first so that media.types.inc
-  // can add the fields specific to a given type (like alt tags on media).
-  // If implemented as an alter, this might not happen, making other alters not
-  // be able to work on those fields.
-  // @TODO: We need to pass in existing values for those attributes.
+  // Similar to a form_alter, but we want this to run first so that
+  // media.types.inc can add the fields specific to a given type (like alt tags
+  // on media). If implemented as an alter, this might not happen, making other
+  // alters not be able to work on those fields.
+  // @todo: We need to pass in existing values for those attributes.
   drupal_alter('media_format_form_prepare', $form, $form_state, $file);
 
   if (!element_children($form['options'])) {
@@ -480,7 +487,7 @@ function media_get_file_without_label($file, $view_mode, $settings = array()) {
  *    carefully to avoid scalability issues with large result sets, and may
  *    not be worth the effort.
  *
- * @param $fid
+ * @param int $fid
  *   Optional media fid being updated. If not given, the cache will be cleared
  *   as long as any file is referenced.
  */
@@ -499,13 +506,13 @@ function media_filter_invalidate_caches($fid = FALSE) {
  * Determines if the {media_filter_usage} table has any entries.
  */
 function media_filter_usage_has_records() {
-  return  (bool) db_query_range('SELECT 1 FROM {media_filter_usage} WHERE fid > :fid', 0, 1, array(':fid' => 0))->fetchField();
+  return (bool) db_query_range('SELECT 1 FROM {media_filter_usage} WHERE fid > :fid', 0, 1, array(':fid' => 0))->fetchField();
 }
 
 /**
  * Tracks usage of media fids by the media filter.
  *
- * @param $fid
+ * @param int $fid
  *   The media fid.
  */
 function media_filter_track_usage($fid) {
diff --git a/includes/media.pages.inc b/includes/media.pages.inc
index 3400e56..8124f3d 100644
--- a/includes/media.pages.inc
+++ b/includes/media.pages.inc
@@ -6,7 +6,7 @@
  */
 
 /**
- *  Menu callback; display a thumbnail for an AJAX preview.
+ * Menu callback; display a thumbnail for an AJAX preview.
  */
 function media_preview_ajax() {
   $url = $_GET['url'];
@@ -28,12 +28,12 @@ function media_preview_ajax() {
 /**
  * Menu callback; Edit multiple files on the same page using multiform module.
  *
+ * @todo When http://drupal.org/node/1227706 is fixed, filter the $files
+ * array using file_access($file, 'edit').
+ *
  * @see media_file_operation_edit_multiple()
  */
 function media_file_page_edit_multiple($files) {
-  // @todo When http://drupal.org/node/1227706 is fixed, filter the $files
-  // array using file_access($file, 'edit').
-
   if (empty($files)) {
     return MENU_ACCESS_DENIED;
   }
diff --git a/includes/media.theme.inc b/includes/media.theme.inc
index b5c82dd..f536deb 100644
--- a/includes/media.theme.inc
+++ b/includes/media.theme.inc
@@ -13,18 +13,19 @@
  *
  * @param array $element
  *   The form element.
+ *
  * @return string
+ *   HTML of the file list
  */
 function theme_media_file_list($element) {
   // Add the CSS for our display.
   return '<div class="media-file-list">' . theme('form_element', $element, $element['#children']) . '</div>';
 }
 
-
-
 /**
  * Theme a thumbnail.
- * @param $variables
+ *
+ * @param array $variables
  *   array items being passed in
  */
 function theme_media_admin_thumbnail($variables) {
@@ -75,30 +76,32 @@ function template_preprocess_media_dialog_page(&$variables) {
 
 /**
  * Adds a wrapper around a preview of a media file.
- * @param unknown_type $element
- * @return unknown_type
  */
 function theme_media_thumbnail($variables) {
   $label = '';
   $element = $variables['element'];
   $destination = drupal_get_destination();
 
-  // Wrappers to go around the thumbnail
+  // Wrappers to go around the thumbnail.
   $prefix = '<div class="media-item" title="' . $element['#name'] . '"><div class="media-thumbnail">';
   $suffix = '</div></div>';
 
-  // Arguments for the thumbnail link
+  // Arguments for the thumbnail link.
   $thumb = $element['#children'];
   $target = 'file/' . $element['#file']->fid . '/edit';
-  $options = array('query' => $destination, 'html' => TRUE, 'attributes' => array('title' => t('Click to edit details')));
+  $options = array(
+    'query' => $destination,
+    'html' => TRUE,
+    'attributes' => array('title' => t('Click to edit details')),
+  );
 
-  // Element should be a field renderable array... This is a little wonky - admitted.
+  // Element should be a field renderable array. This should be improved.
   if (!empty($element['#show_names']) && $element['#name']) {
     $label = '<div class="label-wrapper"><label class="media-filename">' . $element['#name'] . '</label></div>';
   }
 
-  // How can I attach CSS here?
-  //$element['#attached']['css'][] = drupal_get_path('module', 'media') . '/css/media.css';
+  // @todo should CSS be attached to the form element here?
+  // $element['#attached']['css'][] = drupal_get_path('module', 'media') . '/css/media.css';
   drupal_add_css(drupal_get_path('module', 'media') . '/css/media.css');
 
   $output = $prefix;
@@ -112,6 +115,9 @@ function theme_media_thumbnail($variables) {
   return $output;
 }
 
+/**
+ * Preprocess the media thumbnail.
+ */
 function template_preprocess_media_thumbnail(&$variables) {
   // Set the name for the thumbnail to be the filename.  This is done here so
   // that other modules can hijack the name displayed if it should not be the
diff --git a/includes/media.variables.inc b/includes/media.variables.inc
index e3b8cd3..13ae4ac 100644
--- a/includes/media.variables.inc
+++ b/includes/media.variables.inc
@@ -22,49 +22,51 @@ define('MEDIA_TYPES_DEFAULT', '*');
 define('MEDIA_VARIABLE_NAMESPACE', 'media__');
 
 /**
- *  Wrapper for variable_get() that uses the Media variable registry.
+ * Wrapper for variable_get() that uses the Media variable registry.
  *
- *  @param string $name
- *    The variable name to retrieve. Note that it will be namespaced by
- *    pre-pending MEDIA_VARIABLE_NAMESPACE, as to avoid variable collisions with
- *    other modules.
- *  @param unknown $default
- *    An optional default variable to return if the variable hasn't been set
- *    yet. Note that within this module, all variables should already be set
- *    in the media_variable_default() function.
- *  @return unknown
- *    Returns the stored variable or its default.
+ * @param string $name
+ *   The variable name to retrieve. Note that it will be namespaced by
+ *   pre-pending MEDIA_VARIABLE_NAMESPACE, as to avoid variable collisions with
+ *   other modules.
+ * @param unknown $default
+ *   An optional default variable to return if the variable hasn't been set
+ *   yet. Note that within this module, all variables should already be set
+ *   in the media_variable_default() function.
+ *
+ * @return string
+ *   Returns the stored variable or its default.
  *
  *  @see media_variable_set()
  *  @see media_variable_del()
  *  @see media_variable_default()
  */
 function media_variable_get($name, $default = NULL) {
-  // Allow for an override of the default.
-  // Useful when a variable is required (like $path), but namespacing still desired.
+  // Allow for an override of the default. Useful when a variable is required
+  // (like $path), but namespacing still desired.
   if (!isset($default)) {
     $default = media_variable_default($name);
   }
-  // Namespace all variables
+  // Namespace all variables.
   $variable_name = MEDIA_VARIABLE_NAMESPACE . $name;
   return variable_get($variable_name, $default);
 }
 
 /**
- *  Wrapper for variable_set() that uses the Media variable registry.
+ * Wrapper for variable_set() that uses the Media variable registry.
  *
- *  @param string $name
- *    The variable name to set. Note that it will be namespaced by
- *    pre-pending MEDIA_VARIABLE_NAMESPACE, as to avoid variable collisions with
- *    other modules.
- *  @param unknown $value
- *    The value for which to set the variable.
- *  @return unknown
- *    Returns the stored variable after setting.
+ * @param string $name
+ *   The variable name to set. Note that it will be namespaced by
+ *   pre-pending MEDIA_VARIABLE_NAMESPACE, as to avoid variable collisions with
+ *   other modules.
+ * @param unknown $value
+ *   The value for which to set the variable.
  *
- *  @see media_variable_get()
- *  @see media_variable_del()
- *  @see media_variable_default()
+ * @return unknown
+ *   Returns the stored variable after setting.
+ *
+ * @see media_variable_get()
+ * @see media_variable_del()
+ * @see media_variable_default()
  */
 function media_variable_set($name, $value) {
   $variable_name = MEDIA_VARIABLE_NAMESPACE . $name;
@@ -72,16 +74,16 @@ function media_variable_set($name, $value) {
 }
 
 /**
- *  Wrapper for variable_del() that uses the Media variable registry.
+ * Wrapper for variable_del() that uses the Media variable registry.
  *
- *  @param string $name
- *    The variable name to delete. Note that it will be namespaced by
- *    pre-pending MEDIA_VARIABLE_NAMESPACE, as to avoid variable collisions with
- *    other modules.
+ * @param string $name
+ *   The variable name to delete. Note that it will be namespaced by
+ *   pre-pending MEDIA_VARIABLE_NAMESPACE, as to avoid variable collisions with
+ *   other modules.
  *
- *  @see media_variable_get()
- *  @see media_variable_set()
- *  @see media_variable_default()
+ * @see media_variable_get()
+ * @see media_variable_set()
+ * @see media_variable_default()
  */
 function media_variable_del($name) {
   $variable_name = MEDIA_VARIABLE_NAMESPACE . $name;
@@ -96,18 +98,19 @@ function media_variable_name($name) {
 }
 
 /**
- *  The default variables within the Media namespace.
+ * The default variables within the Media namespace.
  *
- *  @param string $name
- *    Optional variable name to retrieve the default. Note that it has not yet
- *    been pre-pended with the MEDIA_VARIABLE_NAMESPACE namespace at this time.
- *  @return unknown
- *    The default value of this variable, if it's been set, or NULL, unless
- *    $name is NULL, in which case we return an array of all default values.
+ * @param string $name
+ *   Optional variable name to retrieve the default. Note that it has not yet
+ *   been pre-pended with the MEDIA_VARIABLE_NAMESPACE namespace at this time.
  *
- *  @see media_variable_get()
- *  @see media_variable_set()
- *  @see media_variable_del()
+ * @return unknown
+ *   The default value of this variable, if it's been set, or NULL, unless
+ *   $name is NULL, in which case we return an array of all default values.
+ *
+ * @see media_variable_get()
+ * @see media_variable_set()
+ * @see media_variable_del()
  */
 function media_variable_default($name = NULL) {
   static $defaults;
@@ -116,7 +119,8 @@ function media_variable_default($name = NULL) {
     $defaults = array(
       'wysiwyg_title' => t('Media browser'),
       'wysiwyg_icon_title' => t('Add media'),
-      //@todo: We should do this per type actually.  For "other" it should be a link.
+      // @todo: We should do this per type actually. For "other" it should be a
+      // link.
       'wysiwyg_default_view_mode' => 'full',
       // Directory to store media uploaded via WYSIWYG.
       'wysiwyg_upload_directory' => '',
@@ -124,10 +128,11 @@ function media_variable_default($name = NULL) {
       'wysiwyg_allowed_types' => array('audio', 'image', 'video'),
       // Attributes which can be modified via the wysiwyg and persist.
       'wysiwyg_allowed_attributes' => array('height', 'width', 'hspace', 'vspace', 'border', 'align', 'style', 'alt', 'title', 'class', 'id'),
-      // WYSIWYG browser plugins in WYSIWYG config page
+      // WYSIWYG browser plugins in WYSIWYG config page.
       'wysiwyg_browser_plugins' => array(),
 
-      // Name of the theme to use in media popup dialogs, defaults to admin_theme
+      // Name of the theme to use in the media popup dialog, defaults to
+      // admin_theme.
       'dialog_theme' => '',
       // @TODO: Make a configuration form with this.
       'file_extensions' => variable_get('file_entity_default_allowed_extensions', 'jpg jpeg gif png txt doc docx xls xlsx pdf ppt pptx pps ppsx odt ods odp') . ' mp3 mov mp4 m4a m4v mpeg avi ogg oga ogv wmv ico',
diff --git a/includes/media.xml.inc b/includes/media.xml.inc
index 36cfd5e..a503bb4 100644
--- a/includes/media.xml.inc
+++ b/includes/media.xml.inc
@@ -1,23 +1,24 @@
 <?php
 
 /**
- *  @file
- *  XML data retrieval and storage API for Media.
+ * @file
+ * XML data retrieval and storage API for Media.
  */
 
 /**
- *  A wrapper around simplexml to retrieve a given XML file.
+ * A wrapper around simplexml to retrieve a given XML file.
  *
- *  @param $url
- *    The URL to the XML to retrieve.
- *  @param $display_errors
- *    Optional; if TRUE, then we'll display errors to the end user. They'll be
- *    logged to the watchdog in any case.
- *  @param $refresh
- *    Optional; if TRUE, then we'll force a new load of the XML. Otherwise,
- *    a cached version will be retrieved if possible.
- *  @return
- *    A fully populated object, or FALSE on an error.
+ * @param string $url
+ *   The URL to the XML to retrieve.
+ * @param bool $display_errors
+ *   Optional; if TRUE, then we'll display errors to the end user. They'll be
+ *   logged to the watchdog in any case.
+ * @param bool $refresh
+ *   Optional; if TRUE, then we'll force a new load of the XML. Otherwise,
+ *   a cached version will be retrieved if possible.
+ *
+ * @return object
+ *   A fully populated object, or FALSE on an error.
  */
 function _media_retrieve_xml($url, $display_errors = FALSE, $refresh = FALSE) {
   $xmls = &drupal_static(__FUNCTION__, array());
@@ -34,7 +35,7 @@ function _media_retrieve_xml($url, $display_errors = FALSE, $refresh = FALSE) {
   // Enable user error handling.
   libxml_use_internal_errors(TRUE);
 
-  // Load the document
+  // Load the document.
   $result = drupal_http_request($url);
   $xml = simplexml_load_string($result->data);
 
@@ -64,9 +65,10 @@ function _media_retrieve_xml($url, $display_errors = FALSE, $refresh = FALSE) {
 }
 
 /**
- *  Recursively converts a SimpleXMLElement object into an array.
- *  @param $xml
- *    The original XML object.
+ * Recursively converts a SimpleXMLElement object into an array.
+ *
+ * @param object $xml
+ *   The original XML object.
  */
 function _media_unserialize_xml($xml) {
   if ($xml instanceof SimpleXMLElement) {
diff --git a/includes/media_views_plugin_style_media_browser.inc b/includes/media_views_plugin_style_media_browser.inc
index e6a4958..4131116 100644
--- a/includes/media_views_plugin_style_media_browser.inc
+++ b/includes/media_views_plugin_style_media_browser.inc
@@ -6,15 +6,17 @@
  */
 
 /**
-// * Style plugin to render media items as an interactive grid for the media
-// * browser.
+ * Media Views style plugin.
+ *
+ * Style plugin to render media items as an interactive grid for the media
+ * browser.
  *
  * @ingroup views_style_plugins
  */
 class media_views_plugin_style_media_browser extends views_plugin_style_list {
 
   // Stores the files loaded with pre_render.
-  var $files = array();
+  public $files = array();
 
   /**
    * Set default options.
@@ -29,14 +31,16 @@ class media_views_plugin_style_media_browser extends views_plugin_style_list {
     return $options;
   }
 
-  // Prevents a problem with views when get_row_class() is not set
-  function get_row_class($row_index) {
+  /**
+   * Prevents a problem with views when get_row_class() is not set.
+   */
+  public function get_row_class($row_index) {
   }
 
   /**
    * Add the base field (fid) to the query.
    */
-  function query() {
+  public function query() {
     if (method_exists($this->view->query, 'add_field')) {
       // Normal file_managed based view.
       $this->view->query->add_field($this->view->base_table, $this->view->base_field);
diff --git a/media.install b/media.install
index 3f6712f..de5d2a7 100644
--- a/media.install
+++ b/media.install
@@ -202,7 +202,7 @@ function media_update_7002() {
   drupal_load('module', 'media');
   $old_types = variable_get('media_types');
   foreach ($old_types as $type) {
-    // Was an error in the original creation
+    // Was an error in the original creation.
     if (isset($type->callbacks)) {
       unset($type->callbacks);
     }
@@ -476,6 +476,8 @@ function media_update_7016() {
 }
 
 /**
+ * Move file display configuration.
+ *
  * Move file display configurations from the 'file_displays' variable to the
  * {file_display} table.
  */
@@ -497,7 +499,10 @@ function media_update_7018() {
 }
 
 /**
- * Update old per-view-mode media field formatters to the generic media formatter with a setting.
+ * Update old view mode formaters.
+ *
+ * Update old per-view-mode media field formatters to the generic media
+ * formatter with a setting.
  */
 function media_update_7019() {
   $instances = array();
@@ -566,7 +571,10 @@ function media_update_7200() {
 }
 
 /**
- * Enable the new Media Field module if this site uses "media" fields. File fields are now preferred for storing media.
+ * Handle existing media fields.
+ *
+ * Enable the new Media Field module if this site uses "media" fields. File
+ * fields are now preferred for storing media.
  */
 function media_update_7201() {
   $fields = field_info_fields();
@@ -578,7 +586,8 @@ function media_update_7201() {
 
       // Update entries in file_usage so that they are associated with Media
       // Field rather than Media.
-      // @TODO This update function may conflict with http://drupal.org/node/1268116
+      // @TODO This update function may conflict with
+      // http://drupal.org/node/1268116
       db_update('file_usage')
         ->condition('module', 'media')
         ->fields(array('module' => 'mediafield'))
@@ -813,15 +822,17 @@ function media_update_7206() {
 }
 
 /**
- * Empty update function to trigger cache clear
- * after changing access callbacks to file_entity_access.
+ * Trigger cache clear.
+ *
+ * Empty update function to trigger cache clear after changing access callbacks
+ * to file_entity_access.
  */
 function media_update_7207() {
   // Do nothing.
 }
 
 /**
- * Drop the media_types table and migrate all files to the new file_entity types.
+ * Drop the media_types table and migrate files to file_entity types.
  */
 function media_update_7208() {
   if (!db_table_exists('media_type')) {
@@ -885,7 +896,7 @@ function media_update_7208() {
     if (!$document_type) {
       return;
     }
-    foreach($mapping['mimetypes'] as $mimetype) {
+    foreach ($mapping['mimetypes'] as $mimetype) {
       $is_document = strpos($mimetype, 'document') !== FALSE || strpos($mimetype, 'application/vnd.ms-') !== FALSE;
       if ($is_document && !in_array($mimetype, $document_type->mimetypes)) {
         $document_type->mimetypes[] = $mimetype;
@@ -950,7 +961,7 @@ function media_update_7210() {
 }
 
 /**
- * Helper function for media_update_7204() to update display options within Views.
+ * Utility function for update 7204. Updates display options within Views.
  */
 function _media_update_7204_update_views_display_options(&$display_options, $view_mode_updates) {
   $updated = FALSE;
diff --git a/media.media.inc b/media.media.inc
index 65738f9..9c77f6a 100644
--- a/media.media.inc
+++ b/media.media.inc
@@ -26,7 +26,8 @@ function media_media_browser_plugin_info() {
         }
         $info["{$view->name}--{$display->id}"] = array(
           'title' => $title,
-          'weight' => $view_weight++, // @TODO make this configurable.
+          // @TODO make this configurable.
+          'weight' => $view_weight++,
           'class' => 'MediaBrowserView',
           'view_name' => $view->name,
           'view_display_id' => $display->id,
@@ -127,7 +128,7 @@ function media_query_media_browser_alter($query) {
   }
 
   // @todo This is possibly redundant since it's already filtered in the view.
-  $query->condition($alias. '.status', FILE_STATUS_PERMANENT);
+  $query->condition($alias . '.status', FILE_STATUS_PERMANENT);
 
   foreach (array_keys(media_get_hidden_stream_wrappers()) as $name) {
     $query->condition($alias . '.uri', db_like($name . '://') . '%', 'NOT LIKE');
diff --git a/media.module b/media.module
index 12d6996..2c23c1e 100644
--- a/media.module
+++ b/media.module
@@ -13,13 +13,13 @@
 /* ***************************************** */
 
 // A registry of variable_get defaults.
-require_once (dirname(__FILE__) . '/includes/media.variables.inc');
+require_once dirname(__FILE__) . '/includes/media.variables.inc';
 
 // Code relating to using media as a field.
-require_once (dirname(__FILE__) . '/includes/media.fields.inc');
+require_once dirname(__FILE__) . '/includes/media.fields.inc';
 
  // Functions for working with [[inline tags]] and wysiwyg editors.
-require_once (dirname(__FILE__) . '/includes/media.filter.inc');
+require_once dirname(__FILE__) . '/includes/media.filter.inc';
 
 /* ***************************************** */
 /* Hook Implementations                      */
@@ -94,7 +94,7 @@ function media_entity_info_alter(&$entity_info) {
 }
 
 /**
- * Access callback for files. Don't use this function, it will be removed!
+ * Access callback for files. This function is depricated.
  *
  * @todo Completely remove this function in favor of file_entity_access after
  * a few releases, to ensure rest of contib catches up.
@@ -104,7 +104,7 @@ function media_access($op, $account = NULL) {
 }
 
 /**
- * Implement of hook_menu().
+ * Implements hook_menu().
  */
 function media_menu() {
   // For managing different types of media and the fields associated with them.
@@ -222,7 +222,7 @@ function media_menu_local_tasks_alter(&$data, $router_item, $root_path) {
 }
 
 /**
- * Implement hook_admin_paths().
+ * Implements hook_admin_paths().
  */
 function media_admin_paths() {
   $paths['media/*/edit/*'] = TRUE;
@@ -309,7 +309,7 @@ function media_image_default_styles() {
         'data' => array('width' => 180, 'height' => 180),
         'weight' => 0,
       ),
-    )
+    ),
   );
   return $styles;
 }
@@ -403,7 +403,8 @@ function media_file_edit_url($fids) {
 
   if (count($fids) > 1) {
     return 'admin/content/file/edit-multiple/' . implode(' ', $fids);
-  } else {
+  }
+  else {
     return 'file/' . reset($fids) . '/edit';
   }
 }
@@ -444,10 +445,11 @@ function media_forms($form_id, $args) {
 /**
  * Implements hook_form_FIELD_UI_FIELD_SETTINGS_FORM_alter().
  *
- * @todo: Respect field settings in 7.x-2.x and handle them in the media widget UI
+ * @todo: Respect field settings in 7.x-2.x and handle them in the media widget
+ * UI.
  */
 function media_form_field_ui_field_settings_form_alter(&$form, &$form_state) {
-  // On file fields that use the media widget we need remove specific fields
+  // On file fields that use the media widget we need remove specific fields.
   if ($form['field']['type']['#value'] == 'file') {
     $fields = field_info_instances($form['#entity_type'], $form['#bundle']);
     if ($fields[$form['field']['field_name']['#value']]['widget']['type'] == 'media_generic') {
@@ -460,10 +462,11 @@ function media_form_field_ui_field_settings_form_alter(&$form, &$form_state) {
 /**
  * Implements hook_form_FIELD_UI_FIELD_EDIT_FORM_alter().
  *
- * @todo: Respect field settings in 7.x-2.x and handle them in the media widget UI
+ * @todo: Respect field settings in 7.x-2.x and handle them in the media widget
+ * UI.
  */
 function media_form_field_ui_field_edit_form_alter(&$form, &$form_state) {
-  // On file fields that use the media widget we need remove specific fields
+  // On file fields that use the media widget we need remove specific fields.
   if ($form['#field']['type'] == 'file' && $form['instance']['widget']['type']['#value'] == 'media_generic') {
     $form['field']['settings']['display_field']['#access'] = FALSE;
     $form['field']['settings']['display_default']['#access'] = FALSE;
@@ -472,7 +475,7 @@ function media_form_field_ui_field_edit_form_alter(&$form, &$form_state) {
     $form['instance']['settings']['file_extensions']['#maxlength'] = 255;
   }
 
-  // On image fields using the media widget we remove the alt/title fields
+  // On image fields using the media widget we remove the alt/title fields.
   if ($form['#field']['type'] == 'image' && $form['instance']['widget']['type']['#value'] == 'media_generic') {
     $form['instance']['settings']['alt_field']['#access'] = FALSE;
     $form['instance']['settings']['title_field']['#access'] = FALSE;
@@ -508,19 +511,18 @@ function media_form_file_entity_edit_alter(&$form, &$form_state) {
 }
 
 /**
- * Alter forms when using the media browser popup to use
- * media_browser_form_submit
+ * When using the media browser popup forms use media_browser_form_submit().
  */
 function media_form_alter(&$form, &$form_state, $form_id) {
   // If we're in the media browser, set the #media_browser key to true
   // so that if an ajax request gets sent to a different path, the form
-  // still uses the media_browser_form_submit callback
+  // still uses the media_browser_form_submit callback.
   if (current_path() == 'media/browser' && $form_id != 'views_exposed_form') {
     $form_state['#media_browser'] = TRUE;
   }
 
   // If the #media_browser key isset and is true we are using the browser
-  // popup, so add the media_browser submit handler
+  // popup, so add the media_browser submit handler.
   if (!empty($form_state['#media_browser'])) {
     $form['#submit'][] = 'media_browser_form_submit';
   }
@@ -533,25 +535,26 @@ function media_browser_form_submit($form, &$form_state) {
   $url = NULL;
   $parameters = array();
 
-  // Single upload
+  // Single upload.
   if (!empty($form_state['file'])) {
     $file = $form_state['file'];
     $url = 'media/browser';
     $parameters = array('query' => array('render' => 'media-popup', 'fid' => $file->fid));
   }
 
-  // Multi upload
+  // Multi upload.
   if (!empty($form_state['files'])) {
     $files = $form_state['files'];
     $url = 'media/browser';
     $parameters = array('query' => array('render' => 'media-popup', 'fid' => array_keys($files)));
   }
 
-  // If $url is set, we had some sort of upload, so redirect
+  // If $url is set there is an upload so redirect.
   if (!empty($url)) {
-    // We the user has access to edit media, we change the redirect to the file-edit url
-    // first, then secondly to the destionation decided above.
-    // @todo maybe check every file separately for update permissions instead of edit any file.
+    // When the user has access to edit media we change the redirect to the
+    // file-edit url first, then the destionation decided above.
+    // @todo maybe check every file separately for update permissions instead of
+    // edit any file.
     if (user_access('edit any files')) {
       $destination = $url . '?' . drupal_http_build_query($parameters['query']);
       $url = media_file_edit_url($parameters['query']['fid']);
@@ -631,12 +634,6 @@ function media_type_page_title($type) {
 
 /**
  * Process callback for the media_browser element.
- *
- * @param $element
- * @param $edit
- * @param $form_state
- * @param $form
- * @return array
  */
 function media_file_list_element_process($element, $edit, $form_state, $form) {
   $element['list'] = array(
@@ -644,7 +641,6 @@ function media_file_list_element_process($element, $edit, $form_state, $form) {
     '#options'  => $element['#options'],
     '#size'     => media_variable_get('file_list_size'),
   );
-
   return $element;
 }
 
@@ -660,13 +656,11 @@ function media_library() {
     'version' => !empty($info['version']) ? $info['version'] : '7.x-2.x',
   );
 
-  /**
-   * Contains libraries common to other media modules.
-   */
+  // Contains libraries common to other media modules.
   $libraries['media_base'] = array(
     'title' => 'Media base',
     'js' => array(
-      $path . '/js/media.core.js' => array('group' => JS_LIBRARY, 'weight' => - 5),
+      $path . '/js/media.core.js' => array('group' => JS_LIBRARY, 'weight' => -5),
       $path . '/js/util/json2.js' => array('group' => JS_LIBRARY),
       $path . '/js/util/ba-debug.min.js' => array('group' => JS_LIBRARY),
     ),
@@ -675,10 +669,8 @@ function media_library() {
     ),
   );
 
-  /**
-   * Includes resources needed to launch the media browser.  Should be included
-   * on pages where the media browser needs to be launched from.
-   */
+  // Includes resources needed to launch the media browser.  Should be included
+  // on pages where the media browser needs to be launched from.
   $libraries['media_browser'] = array(
     'title' => 'Media Browser popup libraries',
     'js' => array(
@@ -692,9 +684,7 @@ function media_library() {
     ),
   );
 
-  /**
-   * Resources needed in the media browser itself.
-   */
+  // Resources needed in the media browser itself.
   $libraries['media_browser_page'] = array(
     'title' => 'Media browser',
     'js' => array(
@@ -720,10 +710,8 @@ function media_library() {
 /**
  * Theme callback used to identify when we are in a popup dialog.
  *
- * We do this because most times the default theme will look terrible in the
- * browser.  So this will default to the administration theme, unless set otherwise.
- *
- * @return string
+ * Generally the default theme will look terrible in the media browser. This
+ * will default to the administration theme, unless set otherwise.
  */
 function media_dialog_get_theme_name() {
   return media_variable_get('dialog_theme', variable_get('admin_theme'));
@@ -732,15 +720,16 @@ function media_dialog_get_theme_name() {
 /**
  * A wrapper around simplexml to retrieve a given XML file.
  *
- * @param $url
+ * @param string $url
  *   The URL to the XML to retrieve.
- * @param $display_errors
+ * @param bool $display_errors
  *   Optional; if TRUE, then we'll display errors to the end user. They'll be
  *   logged to the watchdog in any case.
- * @param $refresh
+ * @param bool $refresh
  *   Optional; if TRUE, then we'll force a new load of the XML. Otherwise,
  *   a cached version will be retrieved if possible.
- * @return
+ *
+ * @return object
  *   A fully populated object, or FALSE on an error.
  */
 function media_retrieve_xml($url, $display_errors = FALSE, $refresh = FALSE) {
@@ -780,11 +769,8 @@ function media_retrieve_xml($url, $display_errors = FALSE, $refresh = FALSE) {
  *
  * @param string $url
  *   The original URL or embed code to parse.
- * @param optional string $form_field
- *   The field from FAPI when being validated, suitable for
- *   form_set_error(). If this is set, then a particular implementation
- *   may throw an error if it believes the URL to be malformed.
- * @return
+ *
+ * @return string
  *   The unique URI for the file, based on its stream wrapper, or NULL.
  *
  * @see media_parse_to_file()
@@ -862,12 +848,9 @@ function media_parse_to_file($url) {
 }
 
 /**
- * Silly function to recursively run check_plain on an array.
- *
- * There is probably something in core I am not aware of that does this.
+ * Utility function to recursively run check_plain on an array.
  *
- * @param $value
- * @param $key
+ * @todo There is probably something in core I am not aware of that does this.
  */
 function media_recursive_check_plain(&$value, $key) {
   $value = check_plain($value);
@@ -881,7 +864,7 @@ function media_element_info() {
   $types['media'] = array(
     '#input' => TRUE,
     '#process' => array('media_element_process'),
-    //'#value_callback' => 'media_element_value',
+    // '#value_callback' => 'media_element_value',
     '#element_validate' => array('media_element_validate'),
     '#theme_wrappers' => array('container'),
     '#progress_indicator' => 'throbber',
@@ -889,8 +872,10 @@ function media_element_info() {
     '#required' => FALSE,
     '#media_options' => array(
       'global' => array(
-        'types' => array(), // Example: array('image', 'audio');
-        'schemes' => array(), // Example: array('http', 'ftp', 'flickr');
+        // Example: array('image', 'audio');
+        'types' => array(),
+        // Example: array('http', 'ftp', 'flickr');
+        'schemes' => array(),
       ),
     ),
     '#attributes' => array(
@@ -899,14 +884,14 @@ function media_element_info() {
     '#attached' => array(
       'library' => array(
         array('media', 'media_browser'),
-        ),
+      ),
     ),
   );
   return $types;
 }
 
 /**
- * #process callback for the media form element.
+ * Process callback for the media form element.
  */
 function media_element_process(&$element, &$form_state, $form) {
   $fid = isset($element['#value']['fid']) ? $element['#value']['fid'] : 0;
@@ -929,7 +914,7 @@ function media_element_process(&$element, &$form_state, $form) {
     '#weight' => -100,
   );
 
-  // @todo This should be loaded from the JS in case of a failed form submission.
+  // @todo This should load from the JS in case of a failed form submission.
   $element['preview'] = array(
     '#prefix' => '<div class="preview launcher">',
     '#suffix' => '</div>',
@@ -947,14 +932,16 @@ function media_element_process(&$element, &$form_state, $form) {
     '#options' => array('fragment' => FALSE, 'external' => TRUE),
     '#weight' => 10,
   );
-  // @todo Figure out how to update the preview image after the Edit modal is closed.
+  // @todo Figure out how to update the preview image after the Edit modal is
+  // closed.
   $element['edit'] = array(
     '#type' => 'link',
     '#href' => 'media/' . $fid . '/edit/nojs',
     '#title' => t('Edit'),
     '#attributes' => array(
       'class' => array(
-        'ctools-use-modal', 'use-ajax', // Required for CTools modal to work.
+        // Required for CTools modal to work.
+        'ctools-use-modal', 'use-ajax',
         'ctools-modal-media-file-edit', 'button', 'edit',
       ),
     ),
@@ -988,18 +975,19 @@ function media_element_process(&$element, &$form_state, $form) {
     'data' => $setting,
   );
 
-  // hmm... Might need to think about this.
-  // All settings would likely apply to all media in a multi-value, but what about passing the existing fid?
-
+  // @todo: Might need to think about this. All settings would likely apply to
+  // all media in a multi-value, but what about passing the existing fid?
   module_load_include('inc', 'media', 'includes/media.browser');
   media_attach_browser_js($element);
 
   return $element;
-  // @todo: make this work for file and image fields
+  // @todo: make this work for file and image fields.
 }
 
 /**
- * Validate media form elements. The file type is validated during the upload process, but this is
+ * Validate media form elements.
+ *
+ * The file type is validated during the upload process, but this is necessary
  * necessary in order to respect the #required property.
  */
 function media_element_validate(&$element, &$form_state) {
@@ -1037,7 +1025,8 @@ function media_filter_info() {
     'description' => t('This filter will convert [[{type:media... ]] tags into markup.'),
     'process callback' => 'media_filter',
     'weight' => 2,
-    'tips callback' => 'media_filter_tips', // @TODO not implemented
+    // @TODO not implemented
+    'tips callback' => 'media_filter_tips',
   );
 
   // If the WYSIWYG module is enabled, add additional help.
@@ -1049,10 +1038,13 @@ function media_filter_info() {
 }
 
 /**
+ * Media thumbnail render function.
+ *
  * Returns a renderable array with the necessary classes to support a media
- * thumbnail.  Also provides default fallback images if no image is available.
+ * thumbnail. Also provides default fallback images if no image is available.
  *
- * @param $file
+ * @param object $file
+ *   A Drupal file object.
  *
  * @return array
  *   Renderable array.
@@ -1072,13 +1064,13 @@ function media_get_thumbnail_preview($file, $link = NULL) {
 /**
  * Check that the media is one of the selected types.
  *
- * @param $file
+ * @param object $file
  *   A Drupal file object.
- * @param $types
+ * @param array $types
  *   An array of media type names
- * @return
- *   An array. If the file type is not allowed, it will contain an error
- *   message.
+ *
+ * @return array
+ *   If the file type is not allowed, it will contain an error message.
  *
  * @see hook_file_validate()
  */
@@ -1182,7 +1174,7 @@ function media_form_file_entity_admin_files_alter(&$form, $form_state) {
   // selected and they try to switch between the "Thumbnail" and "List" local
   // tasks.
   $path = drupal_get_path('module', 'media');
-  require_once($path . '/includes/media.browser.inc');
+  require_once $path . '/includes/media.browser.inc';
   $form['#attributes']['class'][] = 'file-entity-admin-files-form';
   $form['#attached']['js'][] = $path . '/js/media.admin.js';
   $form['#attached']['css'][] = $path . '/css/media.css';
@@ -1229,7 +1221,7 @@ function media_views_api() {
 }
 
 /**
- * Implementation of hook_views_default_views().
+ * Implements hook_views_default_views().
  */
 function media_views_default_views() {
   return media_load_all_exports('media', 'views', 'view.inc', 'view');
@@ -1238,17 +1230,17 @@ function media_views_default_views() {
 /**
  * Fetches an array of exportables from files.
  *
- * @param $module
+ * @param string $module
  *   The module invoking this request. (Can be called by other modules.)
- * @param $directory
+ * @param string $directory
  *   The subdirectory in the custom module.
- * @param $extension
+ * @param string $extension
  *   The file extension.
- * @param $name
+ * @param string $name
  *   The name of the variable found in each file. Defaults to the same as
  *   $extension.
  *
- * @return
+ * @return array
  *   Array of $name objects.
  */
 function media_load_all_exports($module, $directory, $extension, $name = NULL) {
diff --git a/media.views.inc b/media.views.inc
index 8d7b011..e08e17f 100644
--- a/media.views.inc
+++ b/media.views.inc
@@ -7,12 +7,12 @@
 
 /**
  * Implements hook_views_plugins().
+ *
+ * Generate a list of which base-tables to enabled the plugins for.
  */
 function media_views_plugins() {
   $plugins = array();
 
-  // Generate a list of which base-tables to enabled the plugins for.
-
   // Always allow the actual file-table
   $base = array('file_managed');
 
@@ -66,7 +66,9 @@ function template_preprocess_media_views_view_media_browser(&$vars) {
   foreach ($vars['rows'] as $index => $row) {
     // The Search API module returns the row in a slightly different format,
     // so convert it to the format that the normal file_managed table returns.
-    if (!empty($row->entity->fid)) $vars['rows'][$index]->fid = $row->entity->fid;
+    if (!empty($row->entity->fid)) {
+      $vars['rows'][$index]->fid = $row->entity->fid;
+    }
     $fids[$index] = $row->fid;
   }
   $files = file_load_multiple($fids);
@@ -74,7 +76,7 @@ function template_preprocess_media_views_view_media_browser(&$vars) {
   // Render the preview for each file.
   foreach ($vars['rows'] as $index => $row) {
     $file = $files[$row->fid];
-    // Add url/preview to the file object
+    // Add url/preview to the file object.
     media_browser_build_media_item($file);
     $vars['rows'][$index] = $file;
     $vars['rows'][$index]->preview = l($file->preview, 'media/browser', array(
@@ -86,17 +88,17 @@ function template_preprocess_media_views_view_media_browser(&$vars) {
     );
   }
 
-  // Add the files to JS so that they are accessible inside the browser
+  // Add the files to JS so that they are accessible inside the browser.
   drupal_add_js(array('media' => array('files' => array_values($files))), 'setting');
 
-  // Add the browser parameters to the settings and that this display exists
+  // Add the browser parameters to the settings and that this display exists.
   drupal_add_js(array(
     'media' => array(
       'browser' => array(
         'params' => media_get_browser_params(),
         'views' => array(
           $vars['view']->name => array(
-            $vars['view']->current_display
+            $vars['view']->current_display,
           ),
         ),
       ),
@@ -104,7 +106,7 @@ function template_preprocess_media_views_view_media_browser(&$vars) {
   ), 'setting');
 
   // Add classes and wrappers from the style plugin.
-  $handler  = $vars['view']->style_plugin;
+  $handler = $vars['view']->style_plugin;
 
   $class = explode(' ', $handler->options['class']);
   $class = array_map('drupal_clean_css_identifier', $class);
diff --git a/modules/media_internet/media_internet.api.php b/modules/media_internet/media_internet.api.php
index 8400b23..75548f6 100644
--- a/modules/media_internet/media_internet.api.php
+++ b/modules/media_internet/media_internet.api.php
@@ -6,9 +6,10 @@
  */
 
 /**
- * Implementors return an multidim array, keyed by a class name
- * with the following elements:
+ * Implements hook_media_internet_providers().
  *
+ * Implementors return an multidim array, keyed by a class name with the
+ * following elements:
  * - title
  * - image (optional)
  * - hidden: bool If the logo should be shown on form. (optional)
@@ -18,7 +19,7 @@ function hook_media_internet_providers() {
   return array(
     'youtube' => array(
       'title' => 'youtube',
-      'image' => 'youtube.jpg'
+      'image' => 'youtube.jpg',
     ),
   );
 }
diff --git a/modules/media_internet/media_internet.media.inc b/modules/media_internet/media_internet.media.inc
index 3e8b4be..33f9539 100644
--- a/modules/media_internet/media_internet.media.inc
+++ b/modules/media_internet/media_internet.media.inc
@@ -18,7 +18,7 @@ function media_internet_media_browser_plugin_info() {
 }
 
 /**
- * Implements hook_media_internet_providers();
+ * Implements hook_media_internet_providers().
  *
  * Provides a very basic handler which copies files from remote sources to the
  * local files directory.
diff --git a/modules/mediafield/mediafield.install b/modules/mediafield/mediafield.install
index 9a3b150..3e867b8 100644
--- a/modules/mediafield/mediafield.install
+++ b/modules/mediafield/mediafield.install
@@ -26,7 +26,8 @@ function mediafield_field_schema($field) {
         'not null' => FALSE,
         'size' => 'big',
         'serialize' => TRUE,
-        //'description' => 'Used for storing additional information.  Can be harnessed by widgets',
+        // 'description' => 'Used for storing additional information.
+        // Can be harnessed by widgets',
       ),
     ),
     'indexes' => array(
diff --git a/tests/media.entity.test b/tests/media.entity.test
index d735ad6..f2f40de 100644
--- a/tests/media.entity.test
+++ b/tests/media.entity.test
@@ -10,6 +10,9 @@
  */
 class MediaEntityTest extends MediaTestHelper {
 
+  /**
+   * Provides test information.
+   */
   public static function getInfo() {
     return array(
       'name' => 'Media entity',
@@ -21,7 +24,7 @@ class MediaEntityTest extends MediaTestHelper {
   /**
    * Test the ability to create and query media items.
    */
-  function testQueryMedia() {
+  public function testQueryMedia() {
     $text_files = $this->drupalGetTestFiles('text');
     $images = $this->drupalGetTestFiles('image');
 
@@ -29,7 +32,7 @@ class MediaEntityTest extends MediaTestHelper {
     foreach (array_merge($text_files, $images) as $file) {
       // file_uri_to_object triggers a fatal error to d.o testbot.
       // lets remove for now..
-      //$file = file_uri_to_object($file->uri);
+      // $file = file_uri_to_object($file->uri);
       file_save($file);
     }
 
diff --git a/tests/media.test b/tests/media.test
index edd8a62..aaf6dcd 100644
--- a/tests/media.test
+++ b/tests/media.test
@@ -9,7 +9,11 @@
  * Defines base class for media test cases.
  */
 class MediaTestHelper extends DrupalWebTestCase {
-  function setUp() {
+
+  /**
+   * Enable media and file entity modules for testing.
+   */
+  public function setUp() {
     parent::setUp(array('media', 'file_entity'));
   }
 }
diff --git a/wysiwyg_plugins/media.inc b/wysiwyg_plugins/media.inc
index 830fafc..9d0c07c 100644
--- a/wysiwyg_plugins/media.inc
+++ b/wysiwyg_plugins/media.inc
@@ -6,7 +6,7 @@
  */
 
 /**
- * Implementation of WYSIWYG's hook_INCLUDE_plugin().
+ * Implements WYSIWYG's hook_INCLUDE_plugin().
  */
 function media_media_plugin() {
   // Include the required browser JS.
@@ -15,7 +15,7 @@ function media_media_plugin() {
   // @see http://drupal.org/node/1039076
   media_include_browser_js();
 
-  // Plugin definition
+  // Plugin definition.
   $plugins['media'] = array(
     'title' => media_variable_get('wysiwyg_title'),
     'vendor url' => 'http://drupal.org/project/media',
@@ -59,7 +59,8 @@ function media_include_browser_js() {
       // Since the arguments to pass are variable, use call_user_func_array().
       // This will not handle all potential drupal_add_*() functions directly
       // but covers the js and library needed here, which are unlikely to be
-      // expanded since this function is only a workaround for a wysiwyg limitation.
+      // expanded since this function is only a workaround for a wysiwyg
+      // limitation.
       call_user_func_array($function, $definition);
     }
   }
