diff --git a/CHANGELOG.md b/CHANGELOG.md
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,8 @@
 # Changelog for the [`clash-lib`](http://hackage.haskell.org/package/clash-lib) package
 
+## 0.5.1 *April 20th 2015*
+* GHC 7.10 support
+
 ## 0.5 *March 11th 2015*
 * New features:
   * Simplify BlackBox handling, and improve VHDL generation. [#47](https://github.com/clash-lang/clash-compiler/issues/47)
diff --git a/clash-lib.cabal b/clash-lib.cabal
--- a/clash-lib.cabal
+++ b/clash-lib.cabal
@@ -1,5 +1,5 @@
 Name:                 clash-lib
-Version:              0.5
+Version:              0.5.1
 Synopsis:             CAES Language for Synchronous Hardware - As a Library
 Description:
   CλaSH (pronounced ‘clash’) is a functional hardware description language that
@@ -50,12 +50,12 @@
   HS-Source-Dirs:     src
 
   default-language:   Haskell2010
-  ghc-options:        -Wall -fwarn-tabs
+  ghc-options:        -Wall
   CPP-Options:        -DCABAL
 
   Build-depends:      aeson                   >= 0.6.2.0,
                       attoparsec              >= 0.10.4.0,
-                      base                    >= 4.6.0.1 && < 5,
+                      base                    >= 4.8 && < 5,
                       bytestring              >= 0.10.0.2,
                       concurrent-supply       >= 0.1.7,
                       containers              >= 0.5.0.0,
@@ -121,3 +121,4 @@
                       CLaSH.Util
 
   Other-Modules:      Paths_clash_lib
+                      Unbound.Generics.LocallyNameless.Extra
diff --git a/src/CLaSH/Core/DataCon.hs b/src/CLaSH/Core/DataCon.hs
--- a/src/CLaSH/Core/DataCon.hs
+++ b/src/CLaSH/Core/DataCon.hs
@@ -1,4 +1,4 @@
-{-# LANGUAGE DeriveDataTypeable    #-}
+{-# LANGUAGE DeriveAnyClass        #-}
 {-# LANGUAGE DeriveGeneric         #-}
 {-# LANGUAGE FlexibleInstances     #-}
 {-# LANGUAGE MultiParamTypeClasses #-}
@@ -13,15 +13,12 @@
   )
 where
 
-import Data.Monoid                           (mempty)
-import Data.Typeable                         (Typeable)
-import Control.DeepSeq                       (NFData(..))
-import GHC.Generics                          (Generic)
-import Unbound.Generics.LocallyNameless      (Alpha(..),Subst,substs)
-import Unbound.Generics.LocallyNameless.Name (Name(..))
+import Control.DeepSeq                        (NFData(..))
+import GHC.Generics                           (Generic)
+import Unbound.Generics.LocallyNameless       (Alpha(..),Name,Subst(..))
+import Unbound.Generics.LocallyNameless.Extra ()
 
-import {-# SOURCE #-} CLaSH.Core.Term        (Term)
-import {-# SOURCE #-} CLaSH.Core.Type        (TyName, Type)
+import {-# SOURCE #-} CLaSH.Core.Type         (TyName, Type)
 import CLaSH.Util
 
 -- | Data Constructor
@@ -37,7 +34,7 @@
                              -- these type variables are not part of the result
                              -- of the DataCon, but only of the arguments.
   , dcArgTys     :: [Type]   -- ^ Argument types
-  } deriving (Generic,Typeable)
+  } deriving (Generic,NFData)
 
 instance Show DataCon where
   show = show . dcName
@@ -73,18 +70,9 @@
 
   acompare' c dc1 dc2 = acompare' c (dcName dc1) (dcName dc2)
 
-instance Subst Type DataCon
-instance Subst Term DataCon
-
-instance NFData DataCon where
-  rnf dc = case dc of
-    MkData nm tag ty uv ev args -> rnf nm `seq` rnf tag `seq` rnf ty `seq`
-                                   rnf uv `seq` rnf ev `seq` rnf args
-
-instance NFData (Name DataCon) where
-  rnf nm = case nm of
-    (Fn s i) -> rnf s `seq` rnf i
-    (Bn l r) -> rnf l `seq` rnf r
+instance Subst a DataCon where
+  subst _ _ dc = dc
+  substs _ dc  = dc
 
 -- | Given a DataCon and a list of types, the type variables of the DataCon
 -- type are substituted for the list of types. The argument types are returned.
diff --git a/src/CLaSH/Core/DataCon.hs-boot b/src/CLaSH/Core/DataCon.hs-boot
deleted file mode 100644
--- a/src/CLaSH/Core/DataCon.hs-boot
+++ /dev/null
@@ -1,23 +0,0 @@
-{-# LANGUAGE MultiParamTypeClasses #-}
-
-{-# OPTIONS_GHC -fno-warn-missing-methods #-}
-
-module CLaSH.Core.DataCon where
-
-import Control.DeepSeq                  (NFData)
-import GHC.Generics                     (Generic)
-import Unbound.Generics.LocallyNameless (Alpha,Subst)
-
-import {-# SOURCE #-} CLaSH.Core.Term   (Term)
-import {-# SOURCE #-} CLaSH.Core.Type   (Type)
-
-data DataCon
-
-instance Eq      DataCon
-instance Ord     DataCon
-instance Generic DataCon
-instance Show    DataCon
-instance Alpha   DataCon
-instance Subst   Type DataCon
-instance Subst   Term DataCon
-instance NFData  DataCon
diff --git a/src/CLaSH/Core/Literal.hs b/src/CLaSH/Core/Literal.hs
--- a/src/CLaSH/Core/Literal.hs
+++ b/src/CLaSH/Core/Literal.hs
@@ -1,9 +1,8 @@
+{-# LANGUAGE DeriveAnyClass        #-}
 {-# LANGUAGE DeriveGeneric         #-}
 {-# LANGUAGE FlexibleInstances     #-}
 {-# LANGUAGE MultiParamTypeClasses #-}
 
-{-# OPTIONS_GHC -fno-warn-orphans #-}
-
 -- | Term Literal
 module CLaSH.Core.Literal
   ( Literal (..)
@@ -11,37 +10,27 @@
   )
 where
 
-import Control.DeepSeq                  (NFData (..))
-import GHC.Generics                     (Generic)
-import Unbound.Generics.LocallyNameless (Alpha (..), Subst (..))
+import Control.DeepSeq                        (NFData (..))
+import GHC.Generics                           (Generic)
+import Unbound.Generics.LocallyNameless.Extra ()
+import Unbound.Generics.LocallyNameless       (Alpha (..), Subst (..))
 
-import {-# SOURCE #-} CLaSH.Core.Term   (Term)
-import {-# SOURCE #-} CLaSH.Core.Type   (Type)
-import CLaSH.Core.TysPrim               (intPrimTy, voidPrimTy)
-import CLaSH.Util
+import {-# SOURCE #-} CLaSH.Core.Type         (Type)
+import CLaSH.Core.TysPrim                     (intPrimTy, voidPrimTy)
 
 -- | Term Literal
 data Literal
   = IntegerLiteral  Integer
   | StringLiteral   String
   | RationalLiteral Rational
-  deriving (Eq,Ord,Show,Generic)
-
-instance Subst b Rational where
-  subst  _ _ = id
-  substs _   = id
+  deriving (Eq,Ord,Show,Generic,NFData)
 
 instance Alpha Literal where
   fvAny' _ _ l = pure l
 
-instance Subst Type Literal
-instance Subst Term Literal
-
-instance NFData Literal where
-  rnf l = case l of
-    IntegerLiteral i  -> rnf i
-    StringLiteral s   -> rnf s
-    RationalLiteral r -> rnf r
+instance Subst a Literal where
+  subst _ _ l = l
+  substs _ l  = l
 
 -- | Determines the Type of a Literal
 literalType :: Literal
diff --git a/src/CLaSH/Core/Pretty.hs b/src/CLaSH/Core/Pretty.hs
--- a/src/CLaSH/Core/Pretty.hs
+++ b/src/CLaSH/Core/Pretty.hs
@@ -10,7 +10,6 @@
 where
 
 import Data.Char                        (isSymbol, isUpper, ord)
-import Data.Traversable                 (sequenceA)
 import Data.Text                        (unpack)
 import GHC.Show                         (showMultiLineString)
 import Text.PrettyPrint                 (Doc, char, comma, empty, equals, hang,
diff --git a/src/CLaSH/Core/Term.hs b/src/CLaSH/Core/Term.hs
--- a/src/CLaSH/Core/Term.hs
+++ b/src/CLaSH/Core/Term.hs
@@ -1,10 +1,10 @@
-{-# LANGUAGE DeriveDataTypeable    #-}
+{-# LANGUAGE DeriveAnyClass        #-}
 {-# LANGUAGE DeriveGeneric         #-}
 {-# LANGUAGE FlexibleInstances     #-}
 {-# LANGUAGE MultiParamTypeClasses #-}
 {-# LANGUAGE TemplateHaskell       #-}
 
-{-# OPTIONS_GHC -fno-warn-orphans #-}
+{-# OPTIONS_GHC -fno-specialise #-}
 
 -- | Term representation in the CoreHW language: System F + LetRec + Case
 module CLaSH.Core.Term
@@ -17,20 +17,16 @@
 
 -- External Modules
 import Control.DeepSeq
-import Data.Monoid                             (mempty)
 import Data.Text                               (Text)
-import Data.Typeable
 import GHC.Generics
 import Unbound.Generics.LocallyNameless
-import Unbound.Generics.LocallyNameless.Name   (Name(..))
-import Unbound.Generics.LocallyNameless.Unsafe (unsafeUnbind)
+import Unbound.Generics.LocallyNameless.Extra  ()
 
 -- Internal Modules
 import CLaSH.Core.DataCon                      (DataCon)
 import CLaSH.Core.Literal                      (Literal)
 import {-# SOURCE #-} CLaSH.Core.Type          (Type)
 import CLaSH.Core.Var                          (Id, TyVar)
-import CLaSH.Util
 
 -- | Term representation in the CoreHW language: System F + LetRec + Case
 data Term
@@ -45,7 +41,7 @@
   | Letrec  (Bind (Rec [LetBinding]) Term) -- ^ Recursive let-binding
   | Case    Term Type [Bind Pat Term]      -- ^ Case-expression: subject, type of
                                            -- alternatives, list of alternatives
-  deriving (Show,Typeable,Generic)
+  deriving (Show,Generic,NFData)
 
 -- | Term reference
 type TmName     = Name Term
@@ -61,21 +57,7 @@
   -- ^ Literal pattern
   | DefaultPat
   -- ^ Default pattern
-  deriving (Show,Typeable,Generic)
-
-instance Alpha Text where
-  aeq' _ctx             = (==)
-  fvAny' _ctx _nfn i    = pure i
-  close _ctx _b         = id
-  open _ctx _b          = id
-  isPat _               = mempty
-  isTerm _              = True
-  nthPatFind _          = Left
-  namePatFind _ _       = Left 0
-  swaps' _ctx _p        = id
-  freshen' _ctx i       = return (i, mempty)
-  lfreshen' _ctx i cont = cont i mempty
-  acompare' _ctx        = compare
+  deriving (Show,Generic,NFData,Alpha)
 
 instance Eq Term where
   (==) = aeq
@@ -95,59 +77,11 @@
   acompare' _ (Prim t1 _) (Prim t2 _) = compare t1 t2
   acompare' c t1          t2          = gacompare c (from t1) (from t2)
 
-instance Alpha Pat
-
+instance Subst Type Pat
 instance Subst Term Pat
+
 instance Subst Term Term where
   isvar (Var _ x) = Just (SubstName x)
   isvar _         = Nothing
 
-instance Subst Type Pat
-instance Subst Type Term where
-  subst tvN u x | isFreeName tvN = case x of
-    Lam    b         -> Lam    (subst tvN u b  )
-    TyLam  b         -> TyLam  (subst tvN u b  )
-    App    fun arg   -> App    (subst tvN u fun) (subst tvN u arg)
-    TyApp  e   ty    -> TyApp  (subst tvN u e  ) (subst tvN u ty )
-    Letrec b         -> Letrec (subst tvN u b  )
-    Case   e ty alts -> Case   (subst tvN u e  )
-                               (subst tvN u ty )
-                               (subst tvN u alts )
-    Var ty nm        -> Var    (subst tvN u ty ) nm
-    Prim nm ty       -> Prim   nm (subst tvN u ty)
-    e                -> e
-  subst m _ _ = error $ $(curLoc) ++ "Cannot substitute for bound variable: " ++ show m
-
-instance Subst Term Text where
-  subst  _ _ = id
-  substs _   = id
-instance Subst Type Text where
-  subst  _ _ = id
-  substs _   = id
-
-instance NFData Term where
-  rnf tm = case tm of
-    Var     ty nm -> rnf ty `seq` rnf nm
-    Data    dc    -> rnf dc
-    Literal l     -> rnf l
-    Prim    nm ty -> rnf nm `seq` rnf ty
-    Lam     b     -> case unsafeUnbind b of
-                       (id_,tm') -> rnf id_ `seq` rnf tm'
-    TyLam   b       -> case unsafeUnbind b of
-                         (tv,tm') -> rnf tv `seq` rnf tm'
-    App     tmL tmR -> rnf tmL `seq` rnf tmR
-    TyApp   tm' ty  -> rnf tm' `seq` rnf ty
-    Letrec  b       -> case unsafeUnbind b of
-                        (bs,e) -> rnf (map (second unembed) (unrec bs)) `seq` rnf e
-    Case    sc ty alts -> rnf sc `seq` rnf ty `seq` rnf (map unsafeUnbind alts)
-
-instance NFData Pat where
-  rnf p = case p of
-    DataPat dcE xs -> rnf (unembed dcE) `seq` rnf (unrebind xs)
-    LitPat  lE     -> rnf (unembed lE)
-    DefaultPat     -> ()
-
-instance NFData (Name Term) where
-  rnf nm = case nm of
-    (Fn s i) -> rnf s `seq` rnf i
-    (Bn l r) -> rnf l `seq` rnf r
+instance Subst Type Term
diff --git a/src/CLaSH/Core/Term.hs-boot b/src/CLaSH/Core/Term.hs-boot
--- a/src/CLaSH/Core/Term.hs-boot
+++ b/src/CLaSH/Core/Term.hs-boot
@@ -1,17 +1,11 @@
-{-# LANGUAGE MultiParamTypeClasses #-}
-
 {-# OPTIONS_GHC -fno-warn-missing-methods #-}
 
 module CLaSH.Core.Term where
 
 import GHC.Generics                     (Generic)
-import Unbound.Generics.LocallyNameless (Alpha,Name,Subst)
+import Unbound.Generics.LocallyNameless (Name)
 
 data Term
-
 type TmName = Name Term
 
 instance Generic Term
-instance Show    Term
-instance Alpha   Term
-instance Subst   Term Term
diff --git a/src/CLaSH/Core/TyCon.hs b/src/CLaSH/Core/TyCon.hs
--- a/src/CLaSH/Core/TyCon.hs
+++ b/src/CLaSH/Core/TyCon.hs
@@ -1,4 +1,4 @@
-{-# LANGUAGE DeriveDataTypeable    #-}
+{-# LANGUAGE DeriveAnyClass        #-}
 {-# LANGUAGE DeriveGeneric         #-}
 {-# LANGUAGE FlexibleInstances     #-}
 {-# LANGUAGE MultiParamTypeClasses #-}
@@ -16,16 +16,14 @@
 
 -- External Import
 import Control.DeepSeq
-import Data.Monoid                           (mempty)
-import Data.Typeable                         hiding (TyCon,tyConName)
 import GHC.Generics
-import Unbound.Generics.LocallyNameless      (Alpha(..),Subst(..))
-import Unbound.Generics.LocallyNameless.Name (Name(..),name2String)
+import Unbound.Generics.LocallyNameless       (Alpha(..))
+import Unbound.Generics.LocallyNameless.Extra ()
+import Unbound.Generics.LocallyNameless.Name  (Name,name2String)
 
 -- Internal Imports
-import {-# SOURCE #-} CLaSH.Core.DataCon     (DataCon)
-import {-# SOURCE #-} CLaSH.Core.Term        (Term)
-import {-# SOURCE #-} CLaSH.Core.Type        (Kind, TyName, Type)
+import CLaSH.Core.DataCon                     (DataCon)
+import {-# SOURCE #-} CLaSH.Core.Type         (Kind, TyName, Type)
 import CLaSH.Util
 
 -- | Type Constructor
@@ -54,7 +52,7 @@
   | SuperKindTyCon
   { tyConName :: TyConName     -- ^ Name of the TyCon
   }
-  deriving (Generic,Typeable)
+  deriving (Generic,NFData)
 
 instance Show TyCon where
   show (AlgTyCon       {tyConName = n}) = "AlgTyCon: " ++ show n
@@ -84,7 +82,7 @@
                                  -- The TyName's are the type-variables from
                                  -- the corresponding TyCon.
   }
-  deriving (Show,Generic)
+  deriving (Show,Generic,NFData,Alpha)
 
 instance Alpha TyCon where
   aeq' c tc1 tc2      = aeq' c (tyConName tc1) (tyConName tc2)
@@ -105,32 +103,6 @@
   freshen' _ tc       = return (tc,mempty)
 
   acompare' c tc1 tc2 = acompare' c (tyConName tc1) (tyConName tc2)
-
-
-instance Alpha AlgTyConRhs
-
-instance Subst Type TyCon
-instance Subst Type AlgTyConRhs
-
-instance Subst Term TyCon
-instance Subst Term AlgTyConRhs
-
-instance NFData TyCon where
-  rnf tc = case tc of
-    AlgTyCon nm ki ar rhs     -> rnf nm `seq` rnf ki `seq` rnf ar `seq` rnf rhs
-    FunTyCon nm ki ar tcSubst -> rnf nm `seq` rnf ki `seq` rnf ar `seq` rnf tcSubst
-    PrimTyCon nm ki ar        -> rnf nm `seq` rnf ki `seq` rnf ar
-    SuperKindTyCon nm         -> rnf nm
-
-instance NFData (Name TyCon) where
-  rnf nm = case nm of
-    (Fn s i) -> rnf s `seq` rnf i
-    (Bn l r) -> rnf l `seq` rnf r
-
-instance NFData AlgTyConRhs where
-  rnf rhs = case rhs of
-    DataTyCon dcs   -> rnf dcs
-    NewTyCon dc eta -> rnf dc `seq` rnf eta
 
 -- | Create a Kind out of a TyConName
 mkKindTyCon :: TyConName
diff --git a/src/CLaSH/Core/Type.hs b/src/CLaSH/Core/Type.hs
--- a/src/CLaSH/Core/Type.hs
+++ b/src/CLaSH/Core/Type.hs
@@ -1,10 +1,12 @@
-{-# LANGUAGE DeriveDataTypeable    #-}
+{-# LANGUAGE DeriveAnyClass        #-}
 {-# LANGUAGE DeriveGeneric         #-}
 {-# LANGUAGE FlexibleInstances     #-}
 {-# LANGUAGE MultiParamTypeClasses #-}
 {-# LANGUAGE TemplateHaskell       #-}
 {-# LANGUAGE ViewPatterns          #-}
 
+{-# OPTIONS_GHC -fno-specialise #-}
+
 -- | Types in CoreHW
 module CLaSH.Core.Type
   ( Type (..)
@@ -43,15 +45,14 @@
 import           Data.HashMap.Strict                     (HashMap)
 import qualified Data.HashMap.Strict                     as HashMap
 import           Data.Maybe                              (isJust)
-import           Data.Typeable                           hiding (TyCon,mkFunTy,
-                                                          mkTyConApp)
 import           GHC.Generics                            (Generic(..))
 import           Unbound.Generics.LocallyNameless        (Alpha(..),Bind,Fresh,
                                                           Subst(..),SubstName(..),
                                                           acompare,aeq,bind,
                                                           gacompare,gaeq,gfvAny,
                                                           runFreshM,unbind)
-import           Unbound.Generics.LocallyNameless.Name   (Name(..), name2String)
+import           Unbound.Generics.LocallyNameless.Name   (Name,name2String)
+import           Unbound.Generics.LocallyNameless.Extra  ()
 import           Unbound.Generics.LocallyNameless.Unsafe (unsafeUnbind)
 
 -- Local imports
@@ -69,7 +70,7 @@
   | ForAllTy (Bind TyVar Type) -- ^ Polymorphic Type
   | AppTy    Type Type         -- ^ Type Application
   | LitTy    LitTy             -- ^ Type literal
-  deriving (Show,Generic,Typeable)
+  deriving (Show,Generic,NFData)
 
 -- | An easier view on types
 data TypeView
@@ -82,13 +83,13 @@
 data ConstTy
   = TyCon TyConName -- ^ TyCon type
   | Arrow           -- ^ Function type
-  deriving (Show,Generic,Typeable)
+  deriving (Show,Generic,NFData,Alpha)
 
 -- | Literal Types
 data LitTy
   = NumTy Int
   | SymTy String
-  deriving (Show,Generic,Typeable)
+  deriving (Show,Generic,NFData,Alpha)
 
 -- | The level above types
 type Kind       = Type
@@ -110,13 +111,14 @@
   acompare' c (VarTy _ n) (VarTy _ m) = acompare' c n m
   acompare' c t1          t2          = gacompare c (from t1) (from t2)
 
-instance Alpha ConstTy
-instance Alpha LitTy
+instance Subst a LitTy where
+  subst _ _ lt = lt
+  substs _ lt  = lt
 
-instance Subst Type LitTy
-instance Subst Term LitTy
-instance Subst Type ConstTy
-instance Subst Term ConstTy
+instance Subst a ConstTy where
+  subst _ _ ct = ct
+  substs _ ct  = ct
+
 instance Subst Term Type
 instance Subst Type Type where
   isvar (VarTy _ v) = Just (SubstName v)
@@ -127,30 +129,6 @@
 
 instance Ord Type where
   compare = acompare
-
-instance NFData Type where
-  rnf ty = case ty of
-    VarTy    ki nm   -> rnf ki `seq` rnf nm
-    ConstTy  c       -> rnf c
-    ForAllTy b       -> case unsafeUnbind b of
-                          (tv,ty') -> rnf tv `seq` rnf ty'
-    AppTy    tyL tyR -> rnf tyL `seq` rnf tyR
-    LitTy    l       -> rnf l
-
-instance NFData (Name Type) where
-  rnf nm = case nm of
-    (Fn s i) -> rnf s `seq` rnf i
-    (Bn l r) -> rnf l `seq` rnf r
-
-instance NFData ConstTy where
-  rnf cty = case cty of
-    TyCon nm -> rnf nm
-    Arrow    -> ()
-
-instance NFData LitTy where
-  rnf lty = case lty of
-    NumTy i -> rnf i
-    SymTy s -> rnf s
 
 -- | An easier view on types
 tyView :: Type -> TypeView
diff --git a/src/CLaSH/Core/Type.hs-boot b/src/CLaSH/Core/Type.hs-boot
--- a/src/CLaSH/Core/Type.hs-boot
+++ b/src/CLaSH/Core/Type.hs-boot
@@ -5,10 +5,9 @@
 
 module CLaSH.Core.Type where
 
-import Control.DeepSeq
-import Data.Typeable
-import GHC.Generics
-import Unbound.Generics.LocallyNameless
+import Control.DeepSeq                  (NFData)
+import GHC.Generics                     (Generic)
+import Unbound.Generics.LocallyNameless (Alpha,Name,Subst)
 
 import {-# SOURCE #-} CLaSH.Core.Term
 import {-# SOURCE #-} CLaSH.Core.TyCon
@@ -26,7 +25,5 @@
 instance Subst    Type Type
 instance Subst    Term Type
 instance NFData   Type
-instance NFData   (Name Type)
-instance Typeable Type
 
 mkTyConTy :: TyConName -> Type
diff --git a/src/CLaSH/Core/Var.hs b/src/CLaSH/Core/Var.hs
--- a/src/CLaSH/Core/Var.hs
+++ b/src/CLaSH/Core/Var.hs
@@ -1,5 +1,5 @@
 {-# LANGUAGE CPP                   #-}
-{-# LANGUAGE DeriveDataTypeable    #-}
+{-# LANGUAGE DeriveAnyClass        #-}
 {-# LANGUAGE DeriveGeneric         #-}
 {-# LANGUAGE FlexibleContexts      #-}
 {-# LANGUAGE FlexibleInstances     #-}
@@ -20,12 +20,11 @@
 import Control.DeepSeq                  (NFData (..))
 import Data.Typeable                    (Typeable)
 import GHC.Generics                     (Generic)
-import Unbound.Generics.LocallyNameless (Alpha,Embed,Name,Subst(..),isFreeName,
-                                         unembed)
+import Unbound.Generics.LocallyNameless (Alpha,Embed,Name,Subst(..))
+import Unbound.Generics.LocallyNameless.Extra ()
 
 import {-# SOURCE #-} CLaSH.Core.Term   (Term)
 import {-# SOURCE #-} CLaSH.Core.Type   (Kind, Type)
-import CLaSH.Util
 
 -- | Variables in CoreHW
 data Var a
@@ -39,7 +38,7 @@
   { varName :: Name a
   , varType :: Embed Type
   }
-  deriving (Eq,Show,Generic,Typeable)
+  deriving (Eq,Show,Generic,NFData)
 
 -- | Term variable
 type Id    = Var Term
@@ -47,19 +46,8 @@
 type TyVar = Var Type
 
 instance (Typeable a, Alpha a) => Alpha (Var a)
-
-instance Subst Term Id
-instance Subst Term TyVar
-
-instance Subst Type TyVar
-instance Subst Type Id where
-  subst tvN u (Id idN ty) | isFreeName tvN = Id idN (subst tvN u ty)
-  subst m _ _ = error $ $(curLoc) ++ "Cannot substitute for bound variable: " ++ show m
-
-instance NFData (Name a) => NFData (Var a) where
-  rnf v = case v of
-    TyVar nm ki -> rnf nm `seq` rnf (unembed ki)
-    Id    nm ty -> rnf nm `seq` rnf (unembed ty)
+instance Generic b => Subst Term (Var b)
+instance Generic b => Subst Type (Var b)
 
 -- | Change the name of a variable
 modifyVarName ::
diff --git a/src/CLaSH/Netlist/BlackBox.hs b/src/CLaSH/Netlist/BlackBox.hs
--- a/src/CLaSH/Netlist/BlackBox.hs
+++ b/src/CLaSH/Netlist/BlackBox.hs
@@ -11,12 +11,11 @@
 import           Data.Either                   (lefts)
 import qualified Data.HashMap.Lazy             as HashMap
 import qualified Data.IntMap                   as IntMap
-import           Data.Monoid                   (mconcat)
 import           Data.Text.Lazy                (Text, fromStrict, pack)
 import qualified Data.Text.Lazy                as Text
 import           Data.Text                     (unpack)
 import qualified Data.Text                     as TextS
-import           Unbound.Generics.LocallyNameless       (embed, name2String, string2Name,
+import           Unbound.Generics.LocallyNameless (embed, name2String, string2Name,
                                                 unembed)
 
 -- import           CLaSH.Backend                 as N
diff --git a/src/CLaSH/Primitives/Types.hs b/src/CLaSH/Primitives/Types.hs
--- a/src/CLaSH/Primitives/Types.hs
+++ b/src/CLaSH/Primitives/Types.hs
@@ -4,7 +4,7 @@
 -- | Type and instance definitions for Primitive
 module CLaSH.Primitives.Types where
 
-import           Control.Applicative  ((<$>), (<*>), (<|>))
+import           Control.Applicative  ((<|>))
 import           Data.Aeson           (FromJSON (..), Value (..), (.:))
 import           Data.HashMap.Lazy    (HashMap)
 import qualified Data.HashMap.Strict  as H
diff --git a/src/CLaSH/Util.hs b/src/CLaSH/Util.hs
--- a/src/CLaSH/Util.hs
+++ b/src/CLaSH/Util.hs
@@ -21,7 +21,7 @@
 import qualified Control.Monad.State  as State
 import Control.Monad.Trans.Class      (MonadTrans,lift)
 import Data.Function                  as X (on)
-import Data.Hashable                  (Hashable(..),hash)
+import Data.Hashable                  (Hashable)
 import Data.HashMap.Lazy              (HashMap)
 import qualified Data.HashMap.Lazy    as HashMapL
 import qualified Data.HashMap.Strict  as HashMapS
@@ -30,8 +30,6 @@
 import Control.Lens
 import Debug.Trace                    (trace)
 import qualified Language.Haskell.TH  as TH
-import Unbound.Generics.LocallyNameless        (Embed(..))
-import Unbound.Generics.LocallyNameless.Name   (Name(..))
 
 #ifdef CABAL
 import qualified Paths_clash_lib      (version)
@@ -47,13 +45,6 @@
     supply <- State.get
     State.modify (+1)
     return supply
-
-instance Hashable (Name a) where
-  hashWithSalt salt (Fn str int) = hashWithSalt salt (hashWithSalt (hash int) str)
-  hashWithSalt salt (Bn i0  i1)  = hashWithSalt salt (hash i0 `hashWithSalt` i1)
-
-instance (Ord a) => Ord (Embed a) where
-  compare (Embed a) (Embed b) = compare a b
 
 -- | Create a TH expression that returns the a formatted string containing the
 -- name of the module 'curLoc' is spliced into, and the line where it was spliced.
diff --git a/src/Unbound/Generics/LocallyNameless/Extra.hs b/src/Unbound/Generics/LocallyNameless/Extra.hs
new file mode 100644
--- /dev/null
+++ b/src/Unbound/Generics/LocallyNameless/Extra.hs
@@ -0,0 +1,54 @@
+{-# LANGUAGE FlexibleInstances     #-}
+{-# LANGUAGE MultiParamTypeClasses #-}
+
+{-# OPTIONS_GHC -fno-warn-orphans #-}
+
+module Unbound.Generics.LocallyNameless.Extra where
+
+import Control.DeepSeq
+import Data.Hashable                           (Hashable(..),hash)
+import Data.Text                               (Text)
+import GHC.Real                                (Ratio)
+import Unbound.Generics.LocallyNameless.Alpha  (Alpha (..))
+import Unbound.Generics.LocallyNameless.Bind   (Bind (..))
+import Unbound.Generics.LocallyNameless.Embed  (Embed (..))
+import Unbound.Generics.LocallyNameless.Name   (Name (..))
+import Unbound.Generics.LocallyNameless.Rebind (Rebind (..))
+import Unbound.Generics.LocallyNameless.Rec    (Rec,unrec)
+import Unbound.Generics.LocallyNameless.Subst  (Subst (..))
+
+instance (NFData a, NFData b) => NFData (Bind a b)
+instance NFData a => NFData (Embed a)
+instance NFData (Name a)
+instance (NFData a, NFData b) => NFData (Rebind a b)
+instance (Alpha a, NFData a) => NFData (Rec a) where
+  rnf r = seq (rnf (unrec r)) ()
+
+instance Subst b (Ratio a) where
+  subst  _ _ = id
+  substs _   = id
+
+instance Hashable (Name a) where
+  hashWithSalt salt (Fn str int) = hashWithSalt salt (hashWithSalt (hash int) str)
+  hashWithSalt salt (Bn i0  i1)  = hashWithSalt salt (hash i0 `hashWithSalt` i1)
+
+instance (Ord a) => Ord (Embed a) where
+  compare (Embed a) (Embed b) = compare a b
+
+instance Alpha Text where
+  aeq' _ctx             = (==)
+  fvAny' _ctx _nfn i    = pure i
+  close _ctx _b         = id
+  open _ctx _b          = id
+  isPat _               = mempty
+  isTerm _              = True
+  nthPatFind _          = Left
+  namePatFind _ _       = Left 0
+  swaps' _ctx _p        = id
+  freshen' _ctx i       = return (i, mempty)
+  lfreshen' _ctx i cont = cont i mempty
+  acompare' _ctx        = compare
+
+instance Subst b Text where
+  subst  _ _ = id
+  substs _   = id
