diff --git a/Swish/RDF/GraphMatch.hs b/Swish/RDF/GraphMatch.hs
--- a/Swish/RDF/GraphMatch.hs
+++ b/Swish/RDF/GraphMatch.hs
@@ -1,4 +1,5 @@
 {-# LANGUAGE FlexibleInstances, TypeSynonymInstances, MultiParamTypeClasses #-}
+
 --------------------------------------------------------------------------------
 --  See end of this file for licence information.
 --------------------------------------------------------------------------------
diff --git a/Swish/RDF/VarBinding.hs b/Swish/RDF/VarBinding.hs
--- a/Swish/RDF/VarBinding.hs
+++ b/Swish/RDF/VarBinding.hs
@@ -1,4 +1,5 @@
 {-# LANGUAGE MultiParamTypeClasses, TypeSynonymInstances, OverloadedStrings #-}
+{-# LANGUAGE FlexibleInstances #-} -- needed for ghc 7.12
 
 --------------------------------------------------------------------------------
 --  See end of this file for licence information.
@@ -10,7 +11,7 @@
 --
 --  Maintainer  :  Douglas Burke
 --  Stability   :  experimental
---  Portability :  MultiParamTypeClasses, TypeSynonymInstances, OverloadedStrings
+--  Portability :  MultiParamTypeClasses, TypeSynonymInstances, OverloadedStrings, FlexibleInstances
 --
 --  This module defines functions for representing and manipulating query
 --  binding variable sets.  This is the key data that mediates between
diff --git a/swish.cabal b/swish.cabal
--- a/swish.cabal
+++ b/swish.cabal
@@ -1,5 +1,5 @@
 Name:               swish
-Version:            0.5.0.1
+Version:            0.5.0.2
 Stability:          experimental
 License:            LGPL
 License-file:       LICENSE 
@@ -46,6 +46,10 @@
   .
   Changes:
   .
+  [Version 0.5.0.2] HUnit constraint is only added when the @tests@ flag
+  is used. Removed random and bytestring constraints. Add @FlexibleInstances@
+  pragma for ghc 7.2 compatability.
+  .
   [Version 0.5.0.1] Update bounds on package constraints to try and get a
   successful build on ghc 7.2; removed parallel constraint as not used.
   .
@@ -158,18 +162,16 @@
       -- text-format == 0.2.*,
       -- split == 0.1.*,
       binary == 0.5.*,
-      bytestring == 0.9.*,
       containers >= 0.3 && < 0.5,
       array == 0.3.*,
       polyparse >= 1.6 && < 1.8,
-      random == 1.0.*,
       old-locale == 1.0.*, 
       time >= 1.1 && < 1.4,
       mtl >= 1 && < 3,
-      HUnit == 1.2.*,
       network >= 2.2 && < 2.4,
       directory >= 1.0 && < 1.2,
       filepath >= 1.1 && < 1.3
+
    Exposed-Modules:
       Swish
       Swish.RDF
@@ -230,6 +232,10 @@
    if !flag(tests)
       buildable: False
 
+   if flag(tests)
+      Build-Depends: 
+          HUnit == 1.2.*
+
    if flag(hpc)
       ghc-options: -fhpc
 
@@ -246,6 +252,10 @@
    if !flag(tests)
       buildable: False
 
+   if flag(tests)
+      Build-Depends: 
+          HUnit == 1.2.*
+
    if flag(hpc)
       ghc-options: -fhpc
 
@@ -261,6 +271,10 @@
    if !flag(tests)
       buildable: False
 
+   if flag(tests)
+      Build-Depends: 
+          HUnit == 1.2.*
+
    if flag(hpc)
       ghc-options: -fhpc
 
@@ -276,6 +290,10 @@
    if !flag(tests)
       buildable: False
 
+   if flag(tests)
+      Build-Depends: 
+          HUnit == 1.2.*
+
    if flag(hpc)
       ghc-options: -fhpc
 
@@ -291,6 +309,10 @@
    if !flag(tests)
       buildable: False
 
+   if flag(tests)
+      Build-Depends: 
+          HUnit == 1.2.*
+
    if flag(hpc)
       ghc-options: -fhpc
 
@@ -306,6 +328,10 @@
    if !flag(tests)
       buildable: False
 
+   if flag(tests)
+      Build-Depends: 
+          HUnit == 1.2.*
+
    if flag(hpc)
       ghc-options: -fhpc
 
@@ -321,6 +347,10 @@
    if !flag(tests)
       buildable: False
 
+   if flag(tests)
+      Build-Depends: 
+          HUnit == 1.2.*
+
    if flag(hpc)
       ghc-options: -fhpc
 
@@ -336,6 +366,10 @@
    if !flag(tests)
       buildable: False
 
+   if flag(tests)
+      Build-Depends: 
+          HUnit == 1.2.*
+
    if flag(hpc)
       ghc-options: -fhpc
 
@@ -351,6 +385,10 @@
    if !flag(tests)
       buildable: False
                     
+   if flag(tests)
+      Build-Depends: 
+          HUnit == 1.2.*
+
    if flag(hpc)
       ghc-options: -fhpc
 
@@ -366,6 +404,10 @@
    if !flag(tests)
       buildable: False
                      
+   if flag(tests)
+      Build-Depends: 
+          HUnit == 1.2.*
+
    if flag(hpc)
       ghc-options: -fhpc
 
@@ -381,6 +423,10 @@
    if !flag(tests)
       buildable: False
 
+   if flag(tests)
+      Build-Depends: 
+          HUnit == 1.2.*
+
    if flag(hpc)
       ghc-options: -fhpc
 
@@ -396,6 +442,10 @@
    if !flag(tests)
       buildable: False
 
+   if flag(tests)
+      Build-Depends: 
+          HUnit == 1.2.*
+
    if flag(hpc)
       ghc-options: -fhpc
 
@@ -411,6 +461,10 @@
    if !flag(tests)
       buildable: False
 
+   if flag(tests)
+      Build-Depends: 
+          HUnit == 1.2.*
+
    if flag(hpc)
       ghc-options: -fhpc
 
@@ -426,6 +480,10 @@
    if !flag(tests)
       buildable: False
 
+   if flag(tests)
+      Build-Depends: 
+          HUnit == 1.2.*
+
    if flag(hpc)
       ghc-options: -fhpc
 
@@ -440,6 +498,10 @@
    Main-Is:        tests/QNameTest.hs
    if !flag(tests)
       buildable: False
+
+   if flag(tests)
+      Build-Depends: 
+          HUnit == 1.2.*
 
    if flag(hpc)
       ghc-options: -fhpc
