Index: wp-admin/js/media-upload.js
===================================================================
--- wp-admin/js/media-upload.js	(revision 8244)
+++ wp-admin/js/media-upload.js	(working copy)
@@ -5,8 +5,10 @@
 		if (tinymce.isIE)
 			ed.selection.moveToBookmark(tinymce.EditorManager.activeEditor.windowManager.bookmark);
 
+		if ( h.indexOf('[wp_caption') != -1 )
+			h = ed.plugins.wpeditimage._do_shcode(h);
+		
 		ed.execCommand('mceInsertContent', false, h);
-		ed.execCommand('mceCleanup');
 	} else
 		edInsertContent(edCanvas, h);
 
Index: wp-includes/js/tinymce/plugins/wpeditimage/js/editimage.js
===================================================================
--- wp-includes/js/tinymce/plugins/wpeditimage/js/editimage.js	(revision 8244)
+++ wp-includes/js/tinymce/plugins/wpeditimage/js/editimage.js	(working copy)
@@ -460,14 +460,13 @@
 			tinyMCEPopup.close();
 			return;
 		} else {
-			if ( DL ) {
+			if ( DL && DIV ) {
 				if ( f.link_href.value ) html = ed.dom.getOuterHTML(ed.dom.getParent(el, 'a'));
 				else html = ed.dom.getOuterHTML(el);
 				
 				P = ed.dom.create('p', {}, html);
-				DL.parentNode.insertBefore(P,DL);
-				ed.dom.remove(DL.childNodes);
-				ed.dom.remove(DL);
+				DIV.parentNode.insertBefore(P, DIV);
+				ed.dom.remove(DIV);
 			}
 		}
 
Index: wp-includes/js/tinymce/tiny_mce_config.php
===================================================================
--- wp-includes/js/tinymce/tiny_mce_config.php	(revision 8244)
+++ wp-includes/js/tinymce/tiny_mce_config.php	(working copy)
@@ -222,7 +222,7 @@
 // Setup cache info
 if ( $disk_cache ) {
 
-	$cacheKey = apply_filters('tiny_mce_version', '20080626');
+	$cacheKey = apply_filters('tiny_mce_version', '20080702');
 
 	foreach ( $initArray as $v )
 		$cacheKey .= $v;
Index: wp-includes/script-loader.php
===================================================================
--- wp-includes/script-loader.php	(revision 8244)
+++ wp-includes/script-loader.php	(working copy)
@@ -34,7 +34,7 @@
 	$visual_editor = apply_filters('visual_editor', array('tiny_mce'));
 	$scripts->add( 'editor', false, $visual_editor, '20080321' );
 
-	$scripts->add( 'editor_functions', '/wp-admin/js/editor.js', false, '20080701' );
+	$scripts->add( 'editor_functions', '/wp-admin/js/editor.js', false, '20080702' );
 
 	// Modify this version when tinyMCE plugins are changed.
 	$mce_version = apply_filters('tiny_mce_version', '20080701');
@@ -159,7 +159,7 @@
 			'edit' => __('Edit'),
 		) );
 		$scripts->add( 'admin-gallery', '/wp-admin/js/gallery.js', array( 'jquery-ui-sortable' ), '20080520' );
-		$scripts->add( 'media-upload', '/wp-admin/js/media-upload.js', array( 'thickbox' ), '20080701' );
+		$scripts->add( 'media-upload', '/wp-admin/js/media-upload.js', array( 'thickbox' ), '20080702' );
 		$scripts->localize( 'upload', 'uploadL10n', array(
 			'browseTitle' => attribute_escape(__('Browse your files')),
 			'back' => __('&laquo; Back'),
