diff -rupN switchtheme/switchtheme.module switchtheme_new/switchtheme.module
--- switchtheme/switchtheme.module	2009-08-11 09:47:04.000000000 +1000
+++ switchtheme.module	2010-03-29 16:05:09.515986588 +1100
@@ -66,7 +66,8 @@ function switchtheme_menu() {
  * Implementation of hook_init().
  */
 function switchtheme_init() {
-  global $custom_theme, $user;
+  global $custom_theme, $user, $base_root;
+  $new_theme = FALSE;
   drupal_add_css(drupal_get_path('module', 'switchtheme') .'/switchtheme.css');
 
   // If query parameter 'theme' is set, we always assign a new theme.
@@ -82,7 +83,7 @@ function switchtheme_init() {
   // sessions by Drupal core if the "select different theme" permission has
   // been granted.
   if (isset($_SESSION['custom_theme']) && (!isset($custom_theme) || $custom_theme === '0')) {
-    $custom_theme = $_SESSION['custom_theme'];
+    $new_theme = $_SESSION['custom_theme'];
   }
 
   if (module_exists('browscap') && variable_get('switchtheme_browser_enabled', FALSE)) {
@@ -91,10 +92,22 @@ function switchtheme_init() {
       $parent = trim($browser['parent']);
       $browser_theme = variable_get('switchtheme_browser_'. md5($parent), 'default');
       if ($browser_theme != 'default') {
-        $custom_theme = $browser_theme;
+        $new_theme = $browser_theme;
       }
     }
   }
+
+  if ($new_theme && empty($custom_theme)) {
+    $_SESSION['custom_theme'] = $new_theme;
+    $custom_theme = $new_theme;
+    // We shouldn't need cache_clear_all() but we include it in case some more aggressive
+    // caching module that may get added makes it necessary. It is however required in 
+    // switchtheme_switch_form_submit() so if tempted to remove it, leave in it in the 
+    // other function.
+    if (empty($user->uid)) {
+      cache_clear_all($base_root . request_uri(), 'cache_page');
+    }
+  }
 }
 
 /**
@@ -171,7 +184,7 @@ function theme_switchtheme_block_form($f
  * already.
  */
 function switchtheme_switch_form_submit($form, &$form_state) {
-  global $user;
+  global $custom_theme, $user, $base_root;
 
   $themes = switchtheme_options();
   // Bail out if we do not have a valid theme name.
@@ -185,7 +198,15 @@ function switchtheme_switch_form_submit(
   }
   // Otherwise save the setting in the user's session.
   elseif (user_access('switch theme')) {
-    $_SESSION['custom_theme'] = $form_state['values']['theme'];
+    if ($_SESSION['custom_theme'] != $form_state['values']['theme']) {
+      $_SESSION['custom_theme'] = $form_state['values']['theme'];
+      if (empty($custom_theme)) {
+        $custom_theme = $form_state['values']['theme'];
+        if (empty($user->uid)) { 
+          cache_clear_all($base_root . request_uri(), 'cache_page');
+        }
+      }
+    }
   }
 }
 
