diff --git a/hoppy-generator.cabal b/hoppy-generator.cabal
--- a/hoppy-generator.cabal
+++ b/hoppy-generator.cabal
@@ -1,5 +1,5 @@
 name: hoppy-generator
-version: 0.4.0
+version: 0.5.0
 synopsis: C++ FFI generator - Code generator
 homepage: http://khumba.net/projects/hoppy
 license: AGPL-3
diff --git a/src/Foreign/Hoppy/Generator/Language/Cpp/Internal.hs b/src/Foreign/Hoppy/Generator/Language/Cpp/Internal.hs
--- a/src/Foreign/Hoppy/Generator/Language/Cpp/Internal.hs
+++ b/src/Foreign/Hoppy/Generator/Language/Cpp/Internal.hs
@@ -864,7 +864,7 @@
   ifaceHandlers <- interfaceExceptionHandlers <$> askInterface
   moduleHandlers <- getExceptionHandlers <$> askModule
   -- Exception handlers declared lower in the hierarchy take precedence over
-  -- those in the hierarchy; ExceptionHandlers is a left-biased monoid.
+  -- those higher in the hierarchy; ExceptionHandlers is a left-biased monoid.
   return $ mconcat [handlers, moduleHandlers, ifaceHandlers]
 
 getEffectiveCallbackThrows :: Callback -> Generator Bool
diff --git a/src/Foreign/Hoppy/Generator/Language/Haskell/Internal.hs b/src/Foreign/Hoppy/Generator/Language/Haskell/Internal.hs
--- a/src/Foreign/Hoppy/Generator/Language/Haskell/Internal.hs
+++ b/src/Foreign/Hoppy/Generator/Language/Haskell/Internal.hs
@@ -1408,9 +1408,9 @@
                   when (classIsException ancestorCls) $ do
                     let path' = ancestorCls : path
                     ancestorId <- getClassExceptionId ancestorCls
-                    ancestorCastChain <- forM (zip path' $ drop 1 path') $ \(from, to) ->
+                    ancestorCastChain <- forM (zip path' $ drop 1 path') $ \(to, from) ->
                       -- We're upcasting, so 'from' is the subclass.
-                      toHsCastPrimitiveName from to from
+                      toHsCastPrimitiveName from from to
                     saysLn $ concat [ [if first then "[" else ",",
                                        " ( HoppyFHR.ExceptionId ",
                                        show $ getExceptionId ancestorId,
@@ -1684,7 +1684,7 @@
   ifaceHandlers <- interfaceExceptionHandlers <$> askInterface
   moduleHandlers <- getExceptionHandlers <$> askModule
   -- Exception handlers declared lower in the hierarchy take precedence over
-  -- those in the hierarchy; ExceptionHandlers is a left-biased monoid.
+  -- those higher in the hierarchy; ExceptionHandlers is a left-biased monoid.
   return $ mconcat [handlers, moduleHandlers, ifaceHandlers]
 
 getEffectiveCallbackThrows :: Callback -> Generator Bool
diff --git a/src/Foreign/Hoppy/Generator/Spec/Base.hs b/src/Foreign/Hoppy/Generator/Spec/Base.hs
--- a/src/Foreign/Hoppy/Generator/Spec/Base.hs
+++ b/src/Foreign/Hoppy/Generator/Spec/Base.hs
@@ -2294,8 +2294,7 @@
   mempty = ExceptionHandlers []
 
   mappend e1 e2 =
-    ExceptionHandlers
-    (S.toList $ S.fromList $ exceptionHandlersList e1 ++ exceptionHandlersList e2)
+    ExceptionHandlers $ exceptionHandlersList e1 ++ exceptionHandlersList e2
 
 -- | Types that can handle exceptions.
 class HandlesExceptions a where
@@ -2308,7 +2307,7 @@
 -- | Appends additional exception handlers to an object.
 handleExceptions :: HandlesExceptions a => [ExceptionHandler] -> a -> a
 handleExceptions classes =
-  modifyExceptionHandlers $ mappend mempty {exceptionHandlersList = classes}
+  modifyExceptionHandlers $ mappend mempty { exceptionHandlersList = classes }
 
 -- | A literal piece of code that will be inserted into a generated source file
 -- after the regular binding glue.  The 'Monoid' instance concatenates code
