diff --git a/src/calibre/ebooks/html.py b/src/calibre/ebooks/html.py
index f551121f94..f6659f9f51 100644
--- a/src/calibre/ebooks/html.py
+++ b/src/calibre/ebooks/html.py
@@ -836,7 +836,7 @@ class Processor(Parser):
classname = 'calibre_class_%d'%class_counter
class_counter += 1
cache[setting] = classname
- cn = elem.get('class', '')
+ cn = elem.get('class', classname)
elem.set('class', cn)
elem.attrib.pop('style')
diff --git a/src/calibre/ebooks/lit/writer.py b/src/calibre/ebooks/lit/writer.py
index 6d97471d75..5026c9e267 100644
--- a/src/calibre/ebooks/lit/writer.py
+++ b/src/calibre/ebooks/lit/writer.py
@@ -122,6 +122,8 @@ LZXC_CONTROL = \
COLLAPSE = re.compile(r'[ \t\r\n\v]+')
+PAGE_BREAKS = set(['always', 'left', 'right'])
+
def decint(value):
bytes = []
while True:
@@ -202,7 +204,7 @@ class ReBinary(object):
self.write(FLAG_CUSTOM, len(tag)+1, tag)
last_break = self.page_breaks[-1][0] if self.page_breaks else None
if style and last_break != tag_offset \
- and style['page-break-before'] not in ('avoid', 'auto'):
+ and style['page-break-before'] in PAGE_BREAKS:
self.page_breaks.append((tag_offset, list(parents)))
for attr, value in attrib.items():
attr = prefixname(attr, nsrmap)
diff --git a/src/calibre/ebooks/mobi/mobiml.py b/src/calibre/ebooks/mobi/mobiml.py
index afc2fb63ba..eee86754cd 100644
--- a/src/calibre/ebooks/mobi/mobiml.py
+++ b/src/calibre/ebooks/mobi/mobiml.py
@@ -27,7 +27,7 @@ TABLE_TAGS = set(['table', 'tr', 'td', 'th'])
SPECIAL_TAGS = set(['hr', 'br'])
CONTENT_TAGS = set(['img', 'hr', 'br'])
-PAGE_BREAKS = set(['always', 'odd', 'even'])
+PAGE_BREAKS = set(['always', 'left', 'right'])
COLLAPSE = re.compile(r'[ \t\r\n\v]+')
diff --git a/src/calibre/ebooks/oeb/transforms/flatcss.py b/src/calibre/ebooks/oeb/transforms/flatcss.py
index 8a3057787d..28b72b04f3 100644
--- a/src/calibre/ebooks/oeb/transforms/flatcss.py
+++ b/src/calibre/ebooks/oeb/transforms/flatcss.py
@@ -207,7 +207,8 @@ class CSSFlattener(object):
items = cssdict.items()
items.sort()
css = u';\n'.join(u'%s: %s' % (key, val) for key, val in items)
- klass = STRIPNUM.sub('', node.get('class', 'calibre').split()[0])
+ classes = node.get('class', None) or 'calibre'
+ klass = STRIPNUM.sub('', classes.split()[0])
if css in styles:
match = styles[css]
else: