Index: wp-includes/theme.php
===================================================================
--- wp-includes/theme.php	(revision 22275)
+++ wp-includes/theme.php	(working copy)
@@ -1463,23 +1463,22 @@
 
 	switch ( $feature ) {
 		case 'custom-header' :
+			if ( false === did_action( 'wp_loaded', '_custom_header_background_just_in_time' ) )
+				break;
 			$support = get_theme_support( 'custom-header' );
-			if ( isset( $support[0]['wp-head-callback'] ) )
+			if ( $support[0]['wp-head-callback'] )
 				remove_action( 'wp_head', $support[0]['wp-head-callback'] );
-			if ( isset( $GLOBALS['custom_image_header'] ) ) {
-				remove_action( 'admin_menu', array( $GLOBALS['custom_image_header'], 'init' ) );
-				unset( $GLOBALS['custom_image_header'] );
-			}
+			remove_action( 'admin_menu', array( $GLOBALS['custom_image_header'], 'init' ) );
+			unset( $GLOBALS['custom_image_header'] );
 			break;
 
 		case 'custom-background' :
+			if ( false === did_action( 'wp_loaded', '_custom_header_background_just_in_time' ) )
+				break;
 			$support = get_theme_support( 'custom-background' );
-			if ( isset( $support[0]['wp-head-callback'] ) )
-				remove_action( 'wp_head', $support[0]['wp-head-callback'] );
-			if ( isset( $GLOBALS['custom_background'] ) ) {
-				remove_action( 'admin_menu', array( $GLOBALS['custom_background'], 'init' ) );
-				unset( $GLOBALS['custom_background'] );
-			}
+			remove_action( 'wp_head', $support[0]['wp-head-callback'] );
+			remove_action( 'admin_menu', array( $GLOBALS['custom_background'], 'init' ) );
+			unset( $GLOBALS['custom_background'] );
 			break;
 	}
 
