diff --git a/Text/ProtocolBuffers/ProtoCompile/Resolve.hs b/Text/ProtocolBuffers/ProtoCompile/Resolve.hs
--- a/Text/ProtocolBuffers/ProtoCompile/Resolve.hs
+++ b/Text/ProtocolBuffers/ProtoCompile/Resolve.hs
@@ -469,6 +469,8 @@
     (if matchesMain main (top'Package tl) then filteredLookup (top'mVals tl) xs else Nothing)
     <|>
     (matchPrefix (top'Package tl) xs >>= filteredLookup (top'mVals tl))
+    <|>
+    (testPrefix main (top'Package tl) >> filteredLookup (top'mVals tl) xs)
    where matchesMain (PackageID {_getPackageID=a}) (PackageID {_getPackageID=b}) = a==b
          matchesMain (NoPackageID {}) (PackageID {})   = False  -- XXX XXX XXX 2012-09-19 suspicious
          matchesMain (PackageID {})   (NoPackageID {}) = True
@@ -476,6 +478,9 @@
 
          matchPrefix (NoPackageID {}) _ = Nothing
          matchPrefix (PackageID {_getPackageID=a}) ys = stripPrefix a ys
+
+         testPrefix (PackageID {_getPackageID=child}) (PackageID {_getPackageID=parent}) = stripPrefix parent child
+         testPrefix _ _ = Nothing
 
   filteredLookup valsIn namesIn =
     let lookupVals :: EMap -> [IName String] -> Maybe E'Entity
diff --git a/hprotoc.cabal b/hprotoc.cabal
--- a/hprotoc.cabal
+++ b/hprotoc.cabal
@@ -1,5 +1,5 @@
 name:           hprotoc
-version:        2.4.0
+version:        2.4.2
 cabal-version:  >= 1.6
 build-type:     Simple
 license:        BSD3
@@ -20,13 +20,14 @@
   location: git://github.com/k-bx/protocol-buffers.git
 
 Executable hprotoc
-  build-depends:   protocol-buffers == 2.4.0,
-                   protocol-buffers-descriptor == 2.4.0
+  build-depends:   protocol-buffers == 2.4.2,
+                   protocol-buffers-descriptor == 2.4.2
   Main-Is:         Text/ProtocolBuffers/ProtoCompile.hs
   Hs-Source-Dirs:  .,
                    protoc-gen-haskell
   build-tools:     alex
-  ghc-options:     -Wall -fspec-constr-count=10
+  ghc-options:     -O2 -Wall -fspec-constr-count=10
+  -- ghc-prof-options: -O2 -auto-all -prof
   build-depends:   base >= 4.7.0 && < 5,
                    array,
                    binary,
@@ -68,12 +69,13 @@
                    TypeSynonymInstances
 
 Library
-  build-depends:   protocol-buffers == 2.4.0,
-                   protocol-buffers-descriptor == 2.4.0
+  build-depends:   protocol-buffers == 2.4.2,
+                   protocol-buffers-descriptor == 2.4.2
   Hs-Source-Dirs:  .,
                    protoc-gen-haskell
   build-tools:     alex
-  ghc-options:     -Wall -fspec-constr-count=10
+  ghc-options:     -O2 -Wall -fspec-constr-count=10
+  -- ghc-prof-options: -O2 -auto-all -prof
   build-depends:   base >= 4.7.0 && < 5,
                    array,
                    binary,
