diff --git a/src/calibre/ebooks/epub/from_html.py b/src/calibre/ebooks/epub/from_html.py
index c358471f09..458fca152c 100644
--- a/src/calibre/ebooks/epub/from_html.py
+++ b/src/calibre/ebooks/epub/from_html.py
@@ -193,6 +193,8 @@ class HTMLProcessor(Processor, Rationalizer):
for tag in self.root.xpath('//script'):
if not tag.text and not tag.get('src', False):
tag.getparent().remove(tag)
+
+
def save(self):
for meta in list(self.root.xpath('//meta')):
diff --git a/src/calibre/ebooks/html.py b/src/calibre/ebooks/html.py
index f6659f9f51..32601320d4 100644
--- a/src/calibre/ebooks/html.py
+++ b/src/calibre/ebooks/html.py
@@ -417,39 +417,44 @@ class Parser(PreProcessor, LoggingInterface):
self.level = self.htmlfile.level
for f in self.htmlfiles:
name = os.path.basename(f.path)
+ name = os.path.splitext(name)[0] + '.xhtml'
if name in self.htmlfile_map.values():
name = os.path.splitext(name)[0] + '_cr_%d'%save_counter + os.path.splitext(name)[1]
save_counter += 1
self.htmlfile_map[f.path] = name
self.parse_html()
+ # Handle tags inside embedded