diff --git a/advagg.module b/advagg.module
index f924295..945ebb7 100644
--- a/advagg.module
+++ b/advagg.module
@@ -286,7 +286,7 @@ function advagg_modify_js_pre_render($elements) {
 
   // Allow other modules to modify the children before they are rendered.
   // Call hook_advagg_modify_js_pre_render_alter()
-  drupal_alter('advagg_modify_js_pre_render', $children);
+  drupal_alter('advagg_modify_js_pre_render', $children, $elements);
   return $elements;
 }
 
@@ -318,7 +318,7 @@ function advagg_modify_css_pre_render($elements) {
 
   // Allow other modules to modify the children before they are rendered.
   // Call hook_advagg_modify_css_pre_render_alter()
-  drupal_alter('advagg_modify_css_pre_render', $children);
+  drupal_alter('advagg_modify_css_pre_render', $children, $elements);
   return $elements;
 }
 
@@ -437,7 +437,6 @@ function _advagg_aggregate_js(&$js_groups) {
     }
   }
 
-
   if (!empty($files_to_aggregate)) {
     $hooks_hash = advagg_get_current_hooks_hash();
     $js_hash = drupal_hash_base64(serialize($files_to_aggregate));
@@ -478,6 +477,9 @@ function _advagg_process_html(&$variables) {
 
   // JS needs hacks.
   $javascript = advagg_get_full_js();
+  if (!isset($variables['scripts'])) {
+    $variables['scripts'] = '';
+  }
   if (!empty($javascript)) {
     $scopes = advagg_get_js_scopes($javascript);
 
diff --git a/advagg_js_compress/advagg_js_compress.module b/advagg_js_compress/advagg_js_compress.module
index f9552c8..5ae8556 100644
--- a/advagg_js_compress/advagg_js_compress.module
+++ b/advagg_js_compress/advagg_js_compress.module
@@ -66,7 +66,7 @@ function advagg_js_compress_advagg_current_hooks_hash_array_alter(&$aggregate_se
  *
  * Used compress inline js.
  */
-function advagg_js_compress_advagg_modify_js_pre_render_alter(&$children) {
+function advagg_js_compress_advagg_modify_js_pre_render_alter(&$children, &$elements) {
   // Get variables.
   $aggregate_settings['variables']['advagg_js_compressor'] = variable_get('advagg_js_inline_compressor', ADVAGG_JS_INLINE_COMPRESSOR);
   $aggregate_settings['variables']['advagg_js_max_compress_ratio'] = variable_get('advagg_js_max_compress_ratio', ADVAGG_JS_MAX_COMPRESS_RATIO);
diff --git a/advagg_mod/advagg_mod.admin.inc b/advagg_mod/advagg_mod.admin.inc
new file mode 100644
index 0000000..b7b2f84
--- /dev/null
+++ b/advagg_mod/advagg_mod.admin.inc
@@ -0,0 +1,64 @@
+<?php
+
+/**
+ * @file
+ * Admin page callbacks for the advagg bundler module.
+ */
+
+/**
+ * Form builder; Configure advagg settings.
+ *
+ * @ingroup forms
+ * @see system_settings_form()
+ */
+function advagg_mod_admin_settings_form() {
+  $form = array();
+
+  $form['js'] = array(
+    '#type' => 'fieldset',
+    '#title' => t('JS'),
+  );
+  $form['js']['advagg_mod_js_footer'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Move all JS to the footer'),
+    '#default_value' => variable_get('advagg_mod_js_footer', ADVAGG_MOD_JS_FOOTER),
+  );
+  $form['js']['advagg_mod_js_preprocess'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Enable preprocess on all JS'),
+    '#default_value' => variable_get('advagg_mod_js_preprocess', ADVAGG_MOD_JS_PREPROCESS),
+  );
+  $form['js']['advagg_mod_js_defer'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Add the defer tag to all script tags'),
+    '#default_value' => variable_get('advagg_mod_js_defer', ADVAGG_MOD_JS_DEFER),
+    '#description' => t('This will most likely break javascript on different browsers. Use with extreme caution.'),
+  );
+
+  $form['css'] = array(
+    '#type' => 'fieldset',
+    '#title' => t('CSS'),
+  );
+  $form['css']['advagg_mod_css_preprocess'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Enable preprocess on all CSS'),
+    '#default_value' => variable_get('advagg_mod_css_preprocess', ADVAGG_MOD_CSS_PREPROCESS),
+  );
+
+
+  // Clear the cache bins on submit.
+  $form['#submit'][] = 'advagg_mod_admin_settings_form_submit';
+
+  return system_settings_form($form);
+}
+
+// Submit callback.
+/**
+ * Clear out the advagg cache bin when the save configuration button is pressed.
+ */
+function advagg_mod_admin_settings_form_submit($form, &$form_state) {
+  $cache_bins = advagg_flush_caches();
+  foreach ($cache_bins as $bin) {
+    cache_clear_all('*', $bin, TRUE);
+  }
+}
diff --git a/advagg_mod/advagg_mod.info b/advagg_mod/advagg_mod.info
new file mode 100644
index 0000000..8f9cc8a
--- /dev/null
+++ b/advagg_mod/advagg_mod.info
@@ -0,0 +1,5 @@
+name = AdvAgg Modifier
+description = Allows one to alter the CSS and JS array.
+package = Advanced CSS/JS Aggregation
+core = 7.x
+dependencies[] = advagg
diff --git a/advagg_mod/advagg_mod.module b/advagg_mod/advagg_mod.module
new file mode 100644
index 0000000..79e41f8
--- /dev/null
+++ b/advagg_mod/advagg_mod.module
@@ -0,0 +1,147 @@
+<?php
+
+/**
+ * @file
+ * Advanced aggregation modifier module.
+ */
+
+// Define default variables.
+/**
+ * Default value to move all JS to the footer.
+ */
+define('ADVAGG_MOD_JS_FOOTER', FALSE);
+
+/**
+ * Default value to turn on preprocessing for all JavaScript files.
+ */
+define('ADVAGG_MOD_JS_PREPROCESS', FALSE);
+
+/**
+ * Default value to add the defer tag to all script tags.
+ */
+define('ADVAGG_MOD_JS_DEFER', FALSE);
+
+/**
+ * Default value to turn on preprocessing for all CSS files.
+ */
+define('ADVAGG_MOD_CSS_PREPROCESS', FALSE);
+
+// Core hook implementations.
+/**
+ * Implement hook_menu.
+ */
+function advagg_mod_menu() {
+  $items = array();
+  $file_path = drupal_get_path('module', 'advagg_mod');
+
+  $items['admin/config/development/advagg/mod'] = array(
+    'title' => 'Modifications',
+    'description' => 'Turn on or off various mods for CSS/JS.',
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('advagg_mod_admin_settings_form'),
+    'type' => MENU_LOCAL_TASK,
+    'access arguments' => array('administer site configuration'),
+    'file path' => $file_path,
+    'file' => 'advagg_mod.admin.inc',
+    'weight' => 10,
+  );
+
+  return $items;
+}
+
+/**
+ * Implements hook_js_alter().
+ */
+function advagg_mod_js_alter(&$js) {
+  // Move all JS to the footer.
+  if (variable_get('advagg_mod_js_footer', ADVAGG_MOD_JS_FOOTER)) {
+    foreach ($js as $name => &$values) {
+      $values['scope'] = 'footer';
+    }
+  }
+
+  // Force all JS to be preprocessed.
+  if (variable_get('advagg_mod_js_preprocess', ADVAGG_MOD_JS_PREPROCESS)) {
+    foreach ($js as $name => &$values) {
+      $values['preprocess'] = TRUE;
+    }
+  }
+
+  // Add the defer tag to all JS.
+  if (variable_get('advagg_mod_js_defer', ADVAGG_MOD_JS_DEFER)) {
+    foreach ($js as $name => &$values) {
+      // Everything is defer.
+      $values['defer'] = TRUE;
+
+      if (strpos($name, 'jquery.js') !== FALSE || strpos($name, 'jquery.min.js') !== FALSE ) {
+        // Do not defer the loading of jquery.js
+        $values['defer'] = FALSE;
+
+        // jquery_update fallback.
+        if (module_exists('jquery_update')) {
+          $values['onload'] = "if (typeof window.init_drupal_jquery_update_fallback === 'function') {init_drupal_jquery_update_fallback();}";
+        }
+      }
+      if (strpos($name, 'jquery-ui.js') !== FALSE || strpos($name, 'jquery-ui.min.js') !== FALSE ) {
+        // Do not defer the loading of jquery-ui.js
+        $values['defer'] = FALSE;
+
+        // jquery_update fallback.
+        if (module_exists('jquery_update')) {
+          $values['onload'] = "if (typeof window.init_drupal_jquery_ui_update_fallback === 'function') {init_drupal_jquery_ui_update_fallback();}";
+        }
+      }
+
+      // Drupal settings.
+      if ($name == 'misc/drupal.js') {
+        $values['onload'] = "if (typeof window.init_drupal_core_settings === 'function') {init_drupal_core_settings();}";
+      }
+
+    }
+  }
+}
+
+/**
+ * Implements hook_css_alter().
+ */
+function advagg_mod_css_alter(&$css) {
+  // Force all CSS to be preprocessed.
+  if (variable_get('advagg_mod_css_preprocess', ADVAGG_MOD_CSS_PREPROCESS)) {
+    foreach ($css as $name => &$values) {
+      $values['preprocess'] = TRUE;
+    }
+  }
+}
+
+// AdvAgg hook implementations.
+/**
+ * Implements hook_advagg_modify_js_pre_render_alter().
+ */
+function advagg_mod_advagg_modify_js_pre_render_alter(&$children, &$elements) {
+  if (variable_get('advagg_mod_js_defer', ADVAGG_MOD_JS_DEFER)) {
+    foreach ($children as &$values) {
+      $values['#attributes']['defer'] = TRUE;
+      if (empty($values['#value'])) {
+        continue;
+      }
+
+      // Workaround bug with onload and jquery update.
+      if (!empty($values['#attributes']['onload'])) {
+        unset($values['#attributes']['onload']);
+      }
+
+      // Core
+      if (strpos($values['#value'], 'jQuery.extend(Drupal.settings') !== FALSE) {
+        $values['#value'] = 'function init_drupal_core_settings() {' . $values['#value'] . '}';
+      }
+
+      // jQuery Update
+      if (strpos($values['#value'], 'window.jQuery') !== FALSE) {
+        $values['#value'] = 'function init_drupal_jquery_update_fallback() {' . $values['#value'] . '}';
+      }
+      if (strpos($values['#value'], 'window.jQuery.ui') !== FALSE) {
+        $values['#value'] = 'function init_drupal_jquery_ui_update_fallback() {' . $values['#value'] . '}';
+      }
+    }
+  }
+}
