WP 3.3 RC1 new switch_theme() method foobars sidebars

Likely your code is somehow breaking on the new widget handling methods, which save old widget layouts when theme switches occur.

http://wordpress.org/news/2011/11/wherefore-art-thou-widgets/

Most likely, you’ll have to switch themes before adjusting the widgets in it, since widgets don’t survive theme switches anymore, or at least, will be restored from older settings after a theme switch.