diff --git a/sites/all/modules/unl/includes/common.php b/sites/all/modules/unl/includes/common.php
index d332620ca51cea7d5bf5af8e73a1da3cdfde1db4..dcf7ce242f95c1ef6796ad45d52aa5a3a0d7146b 100644
--- a/sites/all/modules/unl/includes/common.php
+++ b/sites/all/modules/unl/includes/common.php
@@ -88,17 +88,17 @@ function unl_get_site_settings($uri) {
   if (!is_readable($settings_file)) {
     throw new Exception('No settings.php exists for site at ' . $uri);
   }
-  
+
   if (is_readable(DRUPAL_ROOT . '/sites/all/settings.php')) {
     require DRUPAL_ROOT . '/sites/all/settings.php';
   }
-  
+
   require $settings_file;
   unset($uri);
   unset($settings_file);
-  
+
   return get_defined_vars();
-} 
+}
 
 /**
  * Custom function that returns TRUE if the given table is shared with another site.
@@ -114,22 +114,65 @@ function unl_table_is_shared($table_name) {
   return FALSE;
 }
 
+/**
+ * Custom function that formats a string of HTML using Tidy
+ * @param string $string
+ */
+function unl_tidy($string) {
+  if (class_exists('Tidy') && variable_get('unl_tidy')) {
+    $tidy = new Tidy();
+
+    // Tidy options: http://tidy.sourceforge.net/docs/quickref.html
+    $options = array(
+      // HTML, XHTML, XML Options
+      'doctype' => 'omit',
+      'new-blocklevel-tags' => 'article,aside,header,footer,section,nav,hgroup,address,figure,figcaption,output',
+      'new-inline-tags' => 'video,audio,canvas,ruby,rt,rp,time,code,kbd,samp,var,mark,bdi,bdo,wbr,details,datalist,source,summary',
+      'output-xhtml' => true,
+      'show-body-only' => true,
+      // Pretty Print
+      'indent' => true,
+      'indent-spaces' => 2,
+      'vertical-space' => false,
+      'wrap' => 140,
+      'wrap-attributes' => false,
+      // Misc
+      'force-output' => true,
+      'quiet' => true,
+      'tidy-mark' => false,
+    );
+
+    // Prevent Tidy from trying to move <script> to the head if it is the first thing
+    if (strtolower(substr(trim($string), 0, 7)) == '<script' || substr(trim($string), 0, 4) == '<!--') {
+      $string = "&nbsp; <!-- Tidy: Start field with something other than script or comment to remove this -->\n" . $string;
+    }
+
+    $tidy->parseString($string, $options, 'utf8');
+    if ($tidy->cleanRepair()) {
+      return $tidy;
+    }
+  }
+
+  return $string;
+}
+
 /**
  * A shared-table safe method that returns TRUE if the user is a member of the super-admin role.
  */
 function unl_user_is_administrator() {
   $user = $GLOBALS['user'];
-  
+
   // If the role table is shared, use parent site's user_admin role, otherwise use the local value.
   if (unl_table_is_shared('role')) {
     $admin_role_id = unl_shared_variable_get('user_admin_role');
-  } else {
-    $admin_role_id = variable_get('user_admin_role'); 
   }
-  
+  else {
+    $admin_role_id = variable_get('user_admin_role');
+  }
+
   if ($user && in_array($admin_role_id, array_keys($user->roles))) {
     return TRUE;
   }
-  
+
   return FALSE;
 }
diff --git a/sites/all/modules/unl/includes/unl.admin.inc b/sites/all/modules/unl/includes/unl.admin.inc
index 59f83c744bd0fe8d833cec0f932ed73fd91750f6..258adb91b26d8be0e2fa419afa1fc4e3ef39bc87 100644
--- a/sites/all/modules/unl/includes/unl.admin.inc
+++ b/sites/all/modules/unl/includes/unl.admin.inc
@@ -4,24 +4,33 @@ function unl_config($form, &$form_state) {
 
   $form['root'] = array(
     '#tree' => TRUE,
-    '#type'  => 'fieldset',
+    '#type' => 'fieldset',
     '#title' => 'UNL Settings',
   );
 
   $form['root']['unl_use_base_tag'] = array(
     '#type' => 'checkbox',
-    '#title' => 'Use Base Tag',
+    '#title' => 'Use base tag',
     '#description' => 'Insert the HTML Base tag in the head of all pages on this site.',
     '#default_value' => variable_get('unl_use_base_tag', TRUE),
   );
-  
+
   $form['root']['unl_clean_file_url'] = array(
     '#type' => 'checkbox',
-    '#title' => 'Clean File URLs',
-    '#description' => 'Enable this once mod_rewrite has been set up to support clean file URLs',
+    '#title' => 'Clean file URLs',
+    '#description' => 'Enable this once mod_rewrite has been set up to support clean file URLs.',
     '#default_value' => variable_get('unl_clean_file_url'),
   );
 
+  if (class_exists('Tidy')) {
+    $form['root']['unl_tidy'] = array(
+      '#type' => 'checkbox',
+      '#title' => 'Clean up text area HTML',
+      '#description' => 'Tidy will be used to process HTML in text areas on the node edit form.',
+      '#default_value' => variable_get('unl_tidy'),
+    );
+  }
+
   $form['submit'] = array(
     '#type' => 'submit',
     '#value' => 'Update',
@@ -33,4 +42,7 @@ function unl_config($form, &$form_state) {
 function unl_config_submit($form, &$form_state) {
   variable_set('unl_use_base_tag', $form_state['values']['root']['unl_use_base_tag']);
   variable_set('unl_clean_file_url', $form_state['values']['root']['unl_clean_file_url']);
+  if (class_exists('Tidy')) {
+    variable_set('unl_tidy', $form_state['values']['root']['unl_tidy']);
+  }
 }
diff --git a/sites/all/modules/unl/unl.module b/sites/all/modules/unl/unl.module
index d5e865610f8342bde5af1b4c50989c8ff4e60aca..ea3a526eadfbda4a3b6409ad986788f8f4442804 100644
--- a/sites/all/modules/unl/unl.module
+++ b/sites/all/modules/unl/unl.module
@@ -172,6 +172,23 @@ function unl_node_prepare($node) {
   $node->menu['expanded'] = 1;
 }
 
+/**
+ * Implementation of hook_node_presave().
+ */
+function unl_node_presave($node) {
+  // Tidy html in fields that are text areas
+  foreach(field_info_instances('node', $node->type) as $field) {
+    if (substr($field['widget']['type'], 0, 13) == 'text_textarea') {
+      $field_name = $field['field_name'];
+      $lang = $node->language;
+      $node_field = $node->$field_name;
+      $tidied_value = unl_tidy($node_field[$lang][0]['value']);
+      $node_field[$lang][0]['value'] = $tidied_value;
+      $node->$field_name = $node_field;
+    }
+  }
+}
+
 /**
  * Implementation of hook_wywiwyg_plugin() found in wysiwyg.api.php
  */
@@ -610,15 +627,6 @@ function unl_form_alter(&$form, $form_state, $form_id) {
   $admin_role_id = unl_shared_variable_get('user_admin_role', -1);
   if (!in_array($admin_role_id, array_keys($GLOBALS['user']->roles))) {
     switch ($form_id) {
-      // Don't allow editing of non-custom content types on admin/structure/types, i.e. don't allow subsites to edit the content types coming from modules or the UNL shared content types
-//       case 'node_type_form' :
-//       case 'field_ui_field_overview_form' :
-//       case 'field_ui_display_overview_form' :
-//         if (!$form['custom']['#value']) {
-//           drupal_access_denied();
-//           exit;
-//         }
-//         break;
       // Add additional validation on admin/people/permissions/roles/edit/%
       case 'user_admin_role' :
         $form['#validate'][] = 'unl_user_admin_role_validate';
@@ -700,18 +708,22 @@ function unl_form_alter(&$form, $form_state, $form_id) {
     }
   }
 
-  /**
-   * On the node edit form, hide the "Provide a menu link" checkbox since we'll
-   * be using the menu to build a site hierarchy.  Instead, add a button that will
-   * determine whether or not the menu link is visible or not.
-   */
-  if (substr($form_id, -10) == '_node_form') {
-    $form['menu']['#title'] = 'Site hierarchy';
+  // Node Edit Form
+  if (isset($form['#node_edit_form']) && $form['#node_edit_form']) {
+    // Tidy existing html in fields that are text areas
+    foreach(field_info_instances($form['#entity_type'], $form['#bundle']) as $field) {
+      if (substr($field['widget']['type'], 0, 13) == 'text_textarea') {
+        $field_name = $field['field_name'];
+        $form[$field_name]['und'][0]['#default_value'] = unl_tidy($form[$field_name]['und'][0]['#default_value']);
+      }
+    }
 
+    // Hide the "Provide a menu link" checkbox since we'll be using the menu to build a site hierarchy.
+    // Instead, add a button that will determine whether or not the menu link is visible.
+    $form['menu']['#title'] = 'Site hierarchy';
     $form['menu']['enabled']['#default_value'] = TRUE;
     $form['menu']['enabled']['#prefix'] = '<div style="display: none;">';
     $form['menu']['enabled']['#suffix'] = '</div>';
-
     $form['menu']['link']['link_title']['#required'] = TRUE;
 
     $mlid = $form['menu']['link']['mlid']['#value'];
@@ -731,7 +743,7 @@ function unl_form_alter(&$form, $form_state, $form_id) {
 
     $form['actions']['submit']['#submit'][] = 'unl_node_form_submit';
 
-    // Also turn on revisioning by default
+    // Also turn on revisioning
     $form['revision_information']['revision']['#default_value'] = TRUE;
     unset($form['revision_information']['revision']['#states']);
   }
@@ -947,7 +959,6 @@ function _unl_cron_import_wdn_registry_sites() {
     );
   }
 
-
   foreach ($sites_to_create as $wdn_site_id => $site_to_create) {
     try {
       db_insert('unl_sites')->fields($site_to_create)->execute();
@@ -1223,7 +1234,7 @@ function unl_still_alive() {
 /**
  * Custom function to return the current admin theme for use with hook_menu_alter().
  */
-function _unl_get_admin_theme(){
+function _unl_get_admin_theme() {
   return variable_get('admin_theme', '0');
 }
 
@@ -1362,8 +1373,7 @@ function unl_block_view($delta = '') {
  * Implements hook_block_view('my_sites').
  * Displays the list of sites/roles for the current user.
  */
-function unl_block_view_my_sites()
-{
+function unl_block_view_my_sites() {
   if (user_is_anonymous()) {
     return array();
   }
@@ -1403,8 +1413,7 @@ class UnlPublicStreamWrapper extends DrupalPublicStreamWrapper {
  * Implements hook_query_alter()
  * Currently used to filter out users with no roles at "admin/people".
  */
-function unl_query_alter(QueryAlterableInterface $query)
-{
+function unl_query_alter(QueryAlterableInterface $query) {
   // If this query is coming from the "People" admin page
   if (current_path() == 'admin/people') {
     // Find the prefix for the "users" table