diff --git a/sites/all/modules/unl/cron.php b/sites/all/modules/unl/cron.php
index be5c6be0d2c4d0d8e31fe26b7614e7f4d31bb83d..a60dae8717205d712ca83dc49eaf0e79b74f94d1 100644
--- a/sites/all/modules/unl/cron.php
+++ b/sites/all/modules/unl/cron.php
@@ -1,8 +1,8 @@
 <?php
 
 if (PHP_SAPI != 'cli') {
-    echo 'This script must be run from the shell!';
-    exit;
+  echo 'This script must be run from the shell!';
+  exit;
 }
 
 chdir(dirname(__FILE__) . '/../../../..');
@@ -14,75 +14,139 @@ drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
 
 $query = db_query('SELECT * FROM {unl_sites} WHERE installed=0');
 while ($row = $query->fetchAssoc()) {
-    db_update('unl_sites')
-        ->fields(array('installed' => 1))
-        ->condition('site_id', $row['site_id'])
-        ->execute();
-    unl_add_site($row['site_path'], $row['uri'], $row['clean_url'], $row['db_prefix']);
-    db_update('unl_sites')
-        ->fields(array('installed' => 2))
-        ->condition('site_id', $row['site_id'])
-        ->execute();
+  db_update('unl_sites')
+   ->fields(array('installed' => 1))
+   ->condition('site_id', $row['site_id'])
+   ->execute();
+  unl_add_site($row['site_path'], $row['uri'], $row['clean_url'], $row['db_prefix']);
+  db_update('unl_sites')
+    ->fields(array('installed' => 2))
+    ->condition('site_id', $row['site_id'])
+    ->execute();
 }
 
+$query = db_query('SELECT * FROM {unl_sites} WHERE installed=3');
+while ($row = $query->fetchAssoc()) {
+  db_update('unl_sites')
+    ->fields(array('installed' => 4))
+    ->condition('site_id', $row['site_id'])
+    ->execute();
+  unl_remove_site($row['site_path'], $row['uri'], $row['db_prefix']);
+  db_update('unl_sites')
+    ->fields(array('installed' => 5))
+    ->condition('site_id', $row['site_id'])
+    ->execute();
+}
 
-function unl_add_site($site_path, $uri, $clean_url, $db_prefix)
-{
-    
-    if (substr($site_path, 0, 1) == '/') {
-        $site_path = substr($site_path, 1);
-    }
-    if (substr($site_path, -1) == '/') {
-        $site_path = substr($site_path, 0, -1);
-    }
-    if (substr($site_path_prefix, 0, 1) == '/') {
-        $site_path_prefix = substr($site_path_prefix, 1);
-    }
-    if (substr($site_path_prefix, -1) == '/') {
-        $site_path_prefix = substr($site_path_prefix, 0, -1);
-    }
-    
-    $full_path = $site_path;
-    if ($site_path_prefix) {
-        $full_path = $site_path_prefix . '/' . $full_path;
-    }
-    
-    $path_parts = parse_url($uri);
-    $sites_subdir = $path_parts['host'] . $path_parts['path'];
-    $sites_subdir = strtr($sites_subdir, array('/' => '.')); 
-    
-    
-    $database = $GLOBALS['databases']['default']['default'];
-    $db_url = $database['driver']
-            . '://' . $database['username']
-            . ':'   . $database['password']
-            . '@'   . $database['host']
-            . ($database['port'] ? ':' . $database['port'] : '') 
-            . '/'   . $database['database']
-            ;
-    $db_prefix .= '_' . $database['prefix'];
-    
-    $php_path = escapeshellarg($_SERVER['_']);
-    $drupal_root = escapeshellarg(DRUPAL_ROOT);
-    $uri = escapeshellarg($uri);
-    $sites_subdir = escapeshellarg($sites_subdir);
-    $db_url = escapeshellarg($db_url);
-    $db_prefix = escapeshellarg($db_prefix);
-    
-    $subdir = explode('/', $full_path);
-    $symlink_name = array_pop($subdir);
-    $subdir_levels = count($subdir);
-    $subdir = implode('/', $subdir);
+
+function unl_add_site($site_path, $uri, $clean_url, $db_prefix) {
+  if (substr($site_path, 0, 1) == '/') {
+    $site_path = substr($site_path, 1);
+  }
+  if (substr($site_path, -1) == '/') {
+    $site_path = substr($site_path, 0, -1);
+  }
+  
+  $path_parts = parse_url($uri);
+  $sites_subdir = $path_parts['host'] . $path_parts['path'];
+  $sites_subdir = strtr($sites_subdir, array('/' => '.')); 
+  
+  
+  $database = $GLOBALS['databases']['default']['default'];
+  $db_url = $database['driver']
+          . '://' . $database['username']
+          . ':'   . $database['password']
+          . '@'   . $database['host']
+          . ($database['port'] ? ':' . $database['port'] : '') 
+          . '/'   . $database['database']
+          ;
+  $db_prefix .= '_' . $database['prefix'];
+  
+  $php_path = escapeshellarg($_SERVER['_']);
+  $drupal_root = escapeshellarg(DRUPAL_ROOT);
+  $uri = escapeshellarg($uri);
+  $sites_subdir = escapeshellarg($sites_subdir);
+  $db_url = escapeshellarg($db_url);
+  $db_prefix = escapeshellarg($db_prefix);
+  
+  $subdir = explode('/', $site_path);
+  $symlink_name = array_pop($subdir);
+  $subdir_levels = count($subdir);
+  $subdir = implode('/', $subdir);
+  
+  $symlink_target = array();
+  for ($i = 0; $i < $subdir_levels; $i++) {
+      $symlink_target[] = '..';
+  }
+  $symlink_target = implode('/', $symlink_target);
+  
+  $command = "$php_path sites/all/modules/drush/drush.php -y --uri=$uri site-install unl_profile --sites-subdir=$sites_subdir --db-url=$db_url --db-prefix=$db_prefix --clean-url=$clean_url";
+  
+  mkdir($subdir, 0755, TRUE);
+  symlink($symlink_target, $subdir . '/' . $symlink_name);
+  shell_exec($command);
+}
+
+function unl_remove_site($site_path, $uri, $db_prefix) {
+  $schema = drupal_get_schema();
+  $tables = array_keys($schema);
+  sort($tables);
     
-    $symlink_target = array();
-    for ($i = 0; $i < $subdir_levels; $i++) {
-        $symlink_target[] = '..';
+  $database = $GLOBALS['databases']['default']['default'];
+  $db_prefix .= '_' . $database['prefix'];
+  
+  
+  $path_parts = parse_url($uri);
+  $sites_subdir = $path_parts['host'] . $path_parts['path'];
+  $sites_subdir = strtr($sites_subdir, array('/' => '.'));
+
+  $sites_subdir = DRUPAL_ROOT . '/sites/' . $sites_subdir;
+  $sites_subdir = realpath($sites_subdir);
+  
+  // A couple checks to make sure we aren't deleting something we shouldn't be.
+  if (substr($sites_subdir, 0, strlen(DRUPAL_ROOT . '/sites/')) != DRUPAL_ROOT . '/sites/') {
+    return;
+  }
+  
+  if (strlen($sites_subdir) <= strlen(DRUPAL_ROOT . '/sites/')) {
+    return;
+  }
+ 
+  foreach ($tables as $table) {
+    $table = $db_prefix . $table;
+    try {
+      db_query("DROP TABLE $table");
+    } catch (PDOException $e) {
+      // probably already gone?
     }
-    $symlink_target = implode('/', $symlink_target);
-    
-    $command = "$php_path sites/all/modules/drush/drush.php -y --uri=$uri site-install unl_profile --sites-subdir=$sites_subdir --db-url=$db_url --db-prefix=$db_prefix --clean-url=$clean_url";
-    
-    mkdir($subdir, 0755, TRUE);
-    symlink($symlink_target, $subdir . '/' . $symlink_name);
-    shell_exec($command);
-}
\ No newline at end of file
+  }
+  
+  shell_exec('chmod -R u+w ' . escapeshellarg($sites_subdir));
+  shell_exec('rm -rf ' . escapeshellarg($sites_subdir));
+  
+  
+  $subdir = explode('/', $site_path);
+  $symlink_name = array_pop($subdir);
+  $subdir_levels = count($subdir);
+  $subdir = implode('/', $subdir);
+  unlink($subdir . '/' . $symlink_name);
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/sites/all/modules/unl/unl_site_creation.php b/sites/all/modules/unl/unl_site_creation.php
index 43c890c8c1f9cbad4634c98a363340a4326759fc..5a9641684897b398a4810e255bb9c57a5a9db933 100644
--- a/sites/all/modules/unl/unl_site_creation.php
+++ b/sites/all/modules/unl/unl_site_creation.php
@@ -87,11 +87,15 @@ function unl_site_list($form, &$form_state) {
     ->fetchAll();
   
   foreach ($sites as $site) {
-    $form['root']['site_' . $site->site_id] = array(
+    $form['root'][$site->site_id] = array(
       'site_path' => array('#value' => $site->site_path),
       'db_prefix' => array('#value' => $site->db_prefix . '_' . $GLOBALS['databases']['default']['default']['prefix']),
       'uri'       => array('#value' => $site->uri),
-      'remove'    => array('#type' => 'checkbox', '#default_value' => 0),
+      'remove'    => array(
+        '#type'          => 'checkbox',
+        '#parents'       => array('sites', $site->site_id, 'remove'),
+      	'#default_value' => 0
+      ),
     );
   }
   
@@ -107,7 +111,7 @@ function unl_site_list($form, &$form_state) {
 function theme_unl_site_list_table($variables) {
   $form = $variables['form'];
   
-  $headers = array('Site Path', 'Datbase Prefix', 'Link', 'Remove (not implemented)');
+  $headers = array('Site Path', 'Datbase Prefix', 'Link', 'Remove (can not undo!)');
   $rows = array();
   foreach (element_children($form) as $key) {
     $rows[] = array(
@@ -123,7 +127,55 @@ function theme_unl_site_list_table($variables) {
   return theme('table', array('header' => $headers, 'rows' => $rows, 'caption' => $form['#title']));
 }
 
+function unl_site_list_submit($form, &$form_state) {
+  if (!isset($form_state['values']['sites'])) {
+    return;
+  }
+  
+  foreach($form_state['values']['sites'] as $site_id => $site) {
+    if ($site['remove']) {
+      unl_site_remove($site_id);
+    }
+  }
+}
 
+function unl_site_remove($site_id) {
+  $uri = db_select('unl_sites', 's')
+    ->fields('s', array('uri'))
+    ->execute()
+    ->fetchCol();
+  
+  if (!isset($uri[0])) {
+    form_set_error(NULL, 'Unfortunately, the site could not be removed.');
+    return;
+  }
+  $uri = $uri[0];
+
+  $path_parts = parse_url($uri);
+  $sites_subdir = $path_parts['host'] . $path_parts['path'];
+  $sites_subdir = strtr($sites_subdir, array('/' => '.'));
+  $sites_subdir = DRUPAL_ROOT . '/sites/' . $sites_subdir;
+  $sites_subdir = realpath($sites_subdir);
+  
+  // A couple checks to make sure we aren't deleting something we shouldn't be.
+  if (substr($sites_subdir, 0, strlen(DRUPAL_ROOT . '/sites/')) != DRUPAL_ROOT . '/sites/') {
+    form_set_error(NULL, 'Unfortunately, the site could not be removed.');
+    return;
+  }
+  
+  if (strlen($sites_subdir) <= strlen(DRUPAL_ROOT . '/sites/')) {
+    form_set_error(NULL, 'Unfortunately, the site could not be removed.');
+    return;
+  }
+  
+  shell_exec('rm -rf ' . escapeshellarg($sites_subdir));
+  
+  db_update('unl_sites')
+    ->fields(array('installed' => 3))
+    ->condition('site_id', $site_id)
+    ->execute();
+  drupal_set_message('The site has been scheduled for removal.');
+}