diff --git a/Data/Aeson/AutoType/CodeGen.hs b/Data/Aeson/AutoType/CodeGen.hs
--- a/Data/Aeson/AutoType/CodeGen.hs
+++ b/Data/Aeson/AutoType/CodeGen.hs
@@ -1,4 +1,5 @@
 {-# LANGUAGE OverloadedStrings #-}
+{-# LANGUAGE ViewPatterns      #-}
 -- | Wrappers for generating prologue and epilogue code in Haskell.
 module Data.Aeson.AutoType.CodeGen(
     writeHaskellModule
@@ -9,6 +10,7 @@
 import qualified Data.Text.IO        as Text
 import           Data.Text
 import qualified Data.HashMap.Strict as Map
+import           Control.Arrow               (first)
 import           System.FilePath
 import           System.IO
 
@@ -44,9 +46,8 @@
   ,"import           Control.Applicative"
   ,"import           Data.Aeson.AutoType.Alternative"
   ,"import           Data.Aeson(decode, Value(..), FromJSON(..), ToJSON(..),"
-  ,"                            (.:), (.:?), (.!=), (.=), object)"
+  ,"                            (.:), (.:?), (.=), object)"
   ,"import           Data.Text (Text)"
-  ,"import           Data.Aeson.TH" 
   ,"import           GHC.Generics" 
   ,""]
 
@@ -82,8 +83,11 @@
       Text.hPutStrLn hOut $ displaySplitTypes types
       Text.hPutStrLn hOut   epilogue
   where
-    (moduleName, extension) = splitExtension $
-                                if     outputFilename == "-"
-                                  then defaultOutputFilename
-                                  else outputFilename
+    (moduleName, extension) =
+       first normalizeTypeName'     $
+       splitExtension               $
+       if     outputFilename == "-"
+         then defaultOutputFilename
+         else outputFilename
+    normalizeTypeName' = Text.unpack . normalizeTypeName . Text.pack
 
diff --git a/Data/Aeson/AutoType/Format.hs b/Data/Aeson/AutoType/Format.hs
--- a/Data/Aeson/AutoType/Format.hs
+++ b/Data/Aeson/AutoType/Format.hs
@@ -7,10 +7,12 @@
 -- | Formatting type declarations and class instances for inferred types. 
 module Data.Aeson.AutoType.Format(
   displaySplitTypes, splitTypeByLabel, unificationCandidates,
-  unifyCandidates
+  unifyCandidates,
+  normalizeTypeName
 ) where
 
 import           Control.Arrow             ((&&&))
+import           Control.Applicative       ((<$>), (<*>))
 import           Control.Lens.TH
 import           Control.Lens
 import           Control.Monad             (forM)
@@ -241,13 +243,16 @@
         formatObjectType (normalizeTypeName name) typ
 
 normalizeTypeName :: Text -> Text
-normalizeTypeName = escapeKeywords           .
-                    escapeFirstNonAlpha      .
-                    Text.concat              .
-                    map capitalize           .
-                    filter (not . Text.null) .
-                    Text.split (not . acceptableInVariable)
+normalizeTypeName s  = ifEmpty "JsonEmptyKey"                  .
+                       escapeKeywords                          .
+                       escapeFirstNonAlpha                     .
+                       Text.concat                             .
+                       map capitalize                          .
+                       filter     (not . Text.null)            .
+                       Text.split (not . acceptableInVariable) $ s
   where
+    ifEmpty x ""       = x
+    ifEmpty _ nonEmpty = nonEmpty
     acceptableInVariable c = isAlpha c || isDigit c
     escapeFirstNonAlpha cs                  | Text.null cs =                   cs
     escapeFirstNonAlpha cs@(Text.head -> c) | isAlpha   c  =                   cs
diff --git a/README.md b/README.md
--- a/README.md
+++ b/README.md
@@ -8,8 +8,9 @@
 
 I should probably write a short paper to explain the methodology.
 
-[![Build Status](https://api.travis-ci.org/mgajda/json-autotype.png?branch=master)](https://travis-ci.org/mgajda/json-autotype)
+[![Build Status](https://api.travis-ci.org/mgajda/json-autotype.svg?branch=master)](https://travis-ci.org/mgajda/json-autotype)
 [![Hackage](https://budueba.com/hackage/json-autotype)](https://hackage.haskell.org/package/json-autotype)
+[![Hackage Dependencies](https://img.shields.io/hackage-deps/v/json-autotype.svg?style=flat)](http://packdeps.haskellers.com/feed?needle=json-autotype)
 
 Details on official releases are on [Hackage](https://hackage.haskell.org/package/json-autotype)
 
diff --git a/changelog.md b/changelog.md
--- a/changelog.md
+++ b/changelog.md
@@ -1,5 +1,11 @@
 Changelog
 =========
+    0.5  Apr 2015
+
+        * Reduced name space pollution when generating code.
+          Now all valid JSON test examples do work.
+        * Corrected build failure on GHC 7.8.4
+
     0.4  Apr 2015
 
         * Release candidate for current functionality.
diff --git a/json-autotype.cabal b/json-autotype.cabal
--- a/json-autotype.cabal
+++ b/json-autotype.cabal
@@ -1,6 +1,6 @@
 -- Build information for the package.
 name:                json-autotype
-version:             0.4
+version:             0.5
 synopsis:            Automatic type declaration for JSON input data
 description:         Generates datatype declarations with Aeson's "FromJSON" instances
                      from a set of example ".json" files.
@@ -32,7 +32,7 @@
 extra-source-files:  README.md changelog.md
 cabal-version:       >=1.10
 bug-reports:         https://github.com/mgajda/json-autotype/issues
-tested-with:         GHC==7.8.4
+tested-with:         GHC==7.8.4,GHC==7.10.1,GHC==7.6.3
 
 source-repository head
   type:     git
@@ -109,10 +109,12 @@
   -- hs-source-dirs:      
   default-language:    Haskell2010
 
--- test suites
-test-suite json-autotype-random-test
+-- * Test suites
+-- Test suite with QuickCheck on random values,
+-- and extracted types.
+test-suite json-autotype-qc-test
   type:                exitcode-stdio-1.0
-  main-is:             GenerateTestJSON.hs
+  main-is:             TestQC.hs
   other-modules:       Data.Aeson.AutoType.Util,
                        Data.Aeson.AutoType.Test,
                        Data.Aeson.AutoType.Type
@@ -132,7 +134,6 @@
                        directory            >=1.1  && <1.3,
                        filepath             >=1.3  && <1.5,
                        hashable             >=1.2  && <1.3,
-                       hflags               >=0.3  && <0.5,
                        lens                 >=4.1  && <4.10,
                        mtl                  >=2.1  && <2.3,
                        pretty               >=1.1  && <1.3,
@@ -147,10 +148,10 @@
   -- hs-source-dirs:      
   default-language:    Haskell2010
 
--- test suite with QuickCheck
-test-suite json-autotype-qc-test
+-- Test suite with Haskell code generation and compilation
+test-suite json-autotype-random-test
   type:                exitcode-stdio-1.0
-  main-is:             TestQC.hs
+  main-is:             GenerateTestJSON.hs
   other-modules:       Data.Aeson.AutoType.Util,
                        Data.Aeson.AutoType.Test,
                        Data.Aeson.AutoType.Type
@@ -170,6 +171,7 @@
                        directory            >=1.1  && <1.3,
                        filepath             >=1.3  && <1.5,
                        hashable             >=1.2  && <1.3,
+                       hflags               >=0.3  && <0.5,
                        lens                 >=4.1  && <4.10,
                        mtl                  >=2.1  && <2.3,
                        pretty               >=1.1  && <1.3,
