diff --git a/Main.hs b/Main.hs
deleted file mode 100644
--- a/Main.hs
+++ /dev/null
@@ -1,27 +0,0 @@
-{-# LANGUAGE OverloadedStrings #-}
-
-module Main where
-
-import Data.Aeson
-import qualified Data.HashMap.Strict as H
-import qualified Data.JsonSchema as JS
-import qualified Data.Vector as V
-
-main :: IO ()
-main =
-  case V.length (JS.isValidSchema rawSchema) of
-    0 -> do
-      eitherGraph <- JS.fetchRefs JS.draft4 rawSchema H.empty
-      case eitherGraph of
-        Left e  -> print e
-        Right g -> print $ JS.validate (JS.compile JS.draft4 g $ rawSchema) invalidData
-    _ -> putStrLn "The schema you tried to use doesn't follow the draft 4 layout."
-
-rawSchema :: JS.RawSchema
-rawSchema = JS.RawSchema
-  { JS._rsURI = ""
-  , JS._rsObject = H.singleton "uniqueItems" (Bool True) -- Schema JSON goes here.
-  }
-
-invalidData :: Value
-invalidData = Array (V.fromList ["foo", "foo"])
diff --git a/hjsonschema.cabal b/hjsonschema.cabal
--- a/hjsonschema.cabal
+++ b/hjsonschema.cabal
@@ -1,5 +1,5 @@
 name:                   hjsonschema
-version:                0.5.1.2
+version:                0.5.1.3
 synopsis:               JSON Schema Draft 4 library
 homepage:               https://github.com/seagreen/hjsonschema
 license:                MIT
@@ -31,7 +31,7 @@
                       , bytestring           >= 0.10  && < 0.11
                       , file-embed           >= 0.0.8 && < 0.0.9
                       , hashable             >= 1.2   && < 1.3
-                      , hjsonpointer         >= 0.1   && < 0.2
+                      , hjsonpointer         >= 0.2   && < 0.3
                       , http-conduit         >= 2.1.5 && < 2.2
                       , http-types           >= 0.8   && < 0.9
                       , regexpr              >= 0.5   && < 0.6
@@ -81,18 +81,6 @@
                       , HUnit                >= 1.2 && < 1.3
                       , test-framework       >= 0.8 && < 0.9
                       , test-framework-hunit >= 0.3 && < 0.4
-
-executable main
-  main-is:            Main.hs
-  default-language:   Haskell2010
-  ghc-options:        -Wall
-  other-extensions:   OverloadedStrings
-
-  build-depends:      aeson
-                    , base
-                    , hjsonschema
-                    , vector
-                    , unordered-containers
 
 source-repository head
   type:               git
diff --git a/src/Data/JsonSchema/Helpers.hs b/src/Data/JsonSchema/Helpers.hs
--- a/src/Data/JsonSchema/Helpers.hs
+++ b/src/Data/JsonSchema/Helpers.hs
@@ -124,6 +124,10 @@
 -- * Utils
 --------------------------------------------------
 
+eitherToMaybe :: Either a b -> Maybe b
+eitherToMaybe (Left _)  = Nothing
+eitherToMaybe (Right a) = Just a
+
 vectorOfElems :: HashMap k a -> Vector a
 vectorOfElems = V.fromList . H.elems
 
diff --git a/src/Data/JsonSchema/Validators.hs b/src/Data/JsonSchema/Validators.hs
--- a/src/Data/JsonSchema/Validators.hs
+++ b/src/Data/JsonSchema/Validators.hs
@@ -426,8 +426,9 @@
 ref spec g s (String val) = do
   (reference, pointer) <- refAndPointer (_rsURI s `combineIdAndRef` val)
   r <- RawSchema reference <$> H.lookup reference g
-  let p = decodeUtf8 . urlDecode True . encodeUtf8 $ pointer
-  case jsonPointer p >>= resolvePointer (Object $ _rsObject r) of
+  let urlDecoded = decodeUtf8 . urlDecode True . encodeUtf8 $ pointer
+  p <- eitherToMaybe $ jsonPointer urlDecoded
+  case resolvePointer p (Object $ _rsObject r) of
     Right (Object o) ->
       Just $ validate $ compile spec g $ RawSchema (_rsURI r) o
     _                -> Nothing
