diff --git a/crf-chain2-tiers.cabal b/crf-chain2-tiers.cabal
--- a/crf-chain2-tiers.cabal
+++ b/crf-chain2-tiers.cabal
@@ -1,5 +1,5 @@
 name:               crf-chain2-tiers
-version:            0.2.1
+version:            0.2.2
 synopsis:           Second-order, tiered, constrained, linear conditional random fields
 description:
     The library provides implementation of the second-order, linear
@@ -33,7 +33,8 @@
       , comonad                 >= 4.0          && < 4.1
       , logfloat                >= 0.12.1       && < 0.13
       , parallel
-      , sgd                     >= 0.3.2 && < 0.4
+      , sgd                     >= 0.3.2        && < 0.4
+      , vector-th-unbox         >= 0.2.1        && < 0.3
 
     exposed-modules:
         Data.CRF.Chain2.Tiers
diff --git a/src/Data/CRF/Chain2/Tiers/Dataset/Codec.hs b/src/Data/CRF/Chain2/Tiers/Dataset/Codec.hs
--- a/src/Data/CRF/Chain2/Tiers/Dataset/Codec.hs
+++ b/src/Data/CRF/Chain2/Tiers/Dataset/Codec.hs
@@ -79,7 +79,7 @@
 
 -- | The empty codec.  The label parts are initialized with Nothing
 -- members, which represent unknown labels.  It is taken in the model
--- implementation on account because it is assigned to the
+-- implementation into account because it is assigned to the
 -- lowest label code and the model assumes that the set of labels
 -- is of the {0, ..., 'lbMax'} form.
 --
diff --git a/src/Data/CRF/Chain2/Tiers/Dataset/Internal.hs b/src/Data/CRF/Chain2/Tiers/Dataset/Internal.hs
--- a/src/Data/CRF/Chain2/Tiers/Dataset/Internal.hs
+++ b/src/Data/CRF/Chain2/Tiers/Dataset/Internal.hs
@@ -1,5 +1,8 @@
 {-# LANGUAGE GeneralizedNewtypeDeriving #-}
 {-# LANGUAGE RecordWildCards #-}
+{-# LANGUAGE TemplateHaskell #-}
+{-# LANGUAGE MultiParamTypeClasses #-}
+{-# LANGUAGE TypeFamilies #-}
 
 
 -- | Internal core data types.
@@ -50,6 +53,7 @@
 import qualified Data.Array.Unboxed as A
 import qualified Data.Vector as V
 import qualified Data.Vector.Unboxed as U
+import           Data.Vector.Unboxed.Deriving
 import qualified Data.Vector.Generic.Base as G
 import qualified Data.Vector.Generic.Mutable as G
 import qualified Data.Number.LogFloat as L
@@ -64,9 +68,10 @@
 
 -- | An observation.
 newtype Ob = Ob { _unOb :: Int32 }
-    deriving ( Show, Eq, Ord, Binary, A.IArray A.UArray
-             , G.Vector U.Vector, G.MVector U.MVector, U.Unbox )
-
+    deriving ( Show, Eq, Ord, Binary, A.IArray A.UArray )
+--           GeneralizedNewtypeDeriving doesn't work for this in 7.8.2:
+--           , G.Vector U.Vector, G.MVector U.MVector, U.Unbox )
+derivingUnbox "Ob" [t| Ob -> Int32 |] [| _unOb |] [| Ob |]
 
 -- | Smart observation constructor.
 mkOb :: Int -> Ob
@@ -83,8 +88,8 @@
 -- | An atomic label.
 newtype Lb = Lb { _unLb :: Int16 }
     deriving ( Show, Eq, Ord, Binary, A.IArray A.UArray
-             , G.Vector U.Vector, G.MVector U.MVector, U.Unbox
              , Num, Ix, Bounds)
+derivingUnbox "Lb" [t| Lb -> Int16 |] [| _unLb |] [| Lb |]
 
 
 -- | Smart label constructor.
@@ -105,9 +110,8 @@
 
 -- | A feature index.  To every model feature a unique index is assigned.
 newtype FeatIx = FeatIx { _unFeatIx :: Int32 }
-    deriving ( Show, Eq, Ord, Binary, A.IArray A.UArray
-             , G.Vector U.Vector, G.MVector U.MVector, U.Unbox )
-
+    deriving ( Show, Eq, Ord, Binary, A.IArray A.UArray )
+derivingUnbox "FeatIx" [t| FeatIx -> Int32 |] [| _unFeatIx |] [| FeatIx |]
 
 -- | Smart feature index constructor.
 mkFeatIx :: Int -> FeatIx
