diff --git a/ChangeLog b/ChangeLog
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+version 0.3.1:
+  - Fix a bug in the Template Haskell code (thanks to lists@snowlion.nl)
+
+version 0.3.0:
+  - Remove gdseq (moved to the regular-extras package due to the introduction
+    of the deepseq dependency).
+
 version 0.2.4:
   - Export Assoc(..) from Generics.Regular.Functions.Crush (thanks to Martijn
     van Steenbergen).
diff --git a/examples/Test.hs b/examples/Test.hs
--- a/examples/Test.hs
+++ b/examples/Test.hs
@@ -11,7 +11,12 @@
 import qualified Generics.Regular.Functions.Read as G
 import Generics.Regular.Functions.Eq
 
+data X = X {one :: Int, three :: Float}
 
+$(deriveAll ''X "Y")
+type instance PF X = Y
+
+{-
 -- Datatype representing logical expressions
 data Logic = Var String
            | Logic :->:  Logic  -- implication
@@ -70,3 +75,4 @@
 
 -- Testing conNames
 ex9 = conNames (undefined :: Logic)
+-}
diff --git a/regular.cabal b/regular.cabal
--- a/regular.cabal
+++ b/regular.cabal
@@ -1,5 +1,5 @@
 name:                   regular
-version:                0.3.0
+version:                0.3.1
 synopsis:               Generic programming library for regular datatypes.
 description:
 
@@ -21,7 +21,7 @@
   \[1] <http://hackage.haskell.org/package/multirec>
 
 category:               Generics
-copyright:              (c) 2010 Universiteit Utrecht
+copyright:              (c) 2011 Universiteit Utrecht
 license:                BSD3
 license-file:           LICENSE
 author:                 Jose Pedro Magalhaes
@@ -29,7 +29,7 @@
 stability:              experimental
 build-type:             Custom
 cabal-version:          >= 1.2.1
-tested-with:            GHC == 6.10.4, GHC == 6.12.1, GHC == 7.0.0.20100925
+tested-with:            GHC == 6.10.4, GHC == 6.12.1, GHC == 7.0.1
 extra-source-files:     examples/Test.hs
                         ChangeLog
                         CREDITS
diff --git a/src/Generics/Regular/TH.hs b/src/Generics/Regular/TH.hs
--- a/src/Generics/Regular/TH.hs
+++ b/src/Generics/Regular/TH.hs
@@ -242,8 +242,8 @@
 pfField d t                         = conT ''K `appT` return t
 
 pfField' :: (Name, [Name]) -> Name -> (Name, Strict, Type) -> Q Type
-pfField' d ns (_, _, t) | t == dataDeclToType d = conT ''I
-pfField' (dt, vs) ns (f, _, t)                  = conT ''S `appT` conT (genName [dt, ns, f]) `appT` (conT ''K `appT` return t)
+pfField' d@(dt, vs) ns (f, _, t) | t == dataDeclToType d = conT ''S `appT` conT (genName [dt, ns, f]) `appT` conT ''I
+pfField'   (dt, vs) ns (f, _, t)                         = conT ''S `appT` conT (genName [dt, ns, f]) `appT` (conT ''K `appT` return t)
 
 mkFrom :: Name -> Int -> Int -> Name -> Q [Q Clause]
 mkFrom ns m i n =
@@ -307,7 +307,7 @@
 fromField (dt, vs) nr t                                = conE 'K `appE` varE (field nr)
 
 fromField' :: (Name, [Name]) -> Int -> (Name, Strict, Type) -> Q Exp
-fromField' (dt, vs) nr (_, _, t) | t == dataDeclToType (dt, vs) = conE 'I `appE` varE (field nr)
+fromField' (dt, vs) nr (_, _, t) | t == dataDeclToType (dt, vs) = conE 'S `appE` (conE 'I `appE` varE (field nr))
 fromField' (dt, vs) nr (_, _, t)                                = conE 'S `appE` (conE 'K `appE` varE (field nr))
 
 toCon :: (Q Pat -> Q Pat) -> Name -> (Name, [Name]) -> Int -> Int -> Con -> Q Clause
@@ -340,7 +340,7 @@
 toField (dt, vs) nr t                                = conP 'K [varP (field nr)]
 
 toField' :: (Name, [Name]) -> Int -> (Name, Strict, Type) -> Q Pat
-toField' (dt, vs) nr (_, _, t) | t == dataDeclToType (dt, vs) = conP 'I [varP (field nr)]
+toField' (dt, vs) nr (_, _, t) | t == dataDeclToType (dt, vs) = conP 'S [conP 'I [varP (field nr)]]
 toField' (dt, vs) nr (_, _, t)                                = conP 'S [conP 'K [varP (field nr)]]
 
 field :: Int -> Name
