diff --git a/LICENSE b/LICENSE
--- a/LICENSE
+++ b/LICENSE
@@ -1,26 +1,26 @@
-Copyright (c) Erik Charlebois.
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions
-are met:
-1. Redistributions of source code must retain the above copyright
-   notice, this list of conditions and the following disclaimer.
-2. Redistributions in binary form must reproduce the above copyright
-   notice, this list of conditions and the following disclaimer in the
-   documentation and/or other materials provided with the distribution.
-3. The names of the author may not be used to endorse or promote
-   products derived from this software without specific prior written
-   permission.
-
-THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
-ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
-FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-SUCH DAMAGE.
+Copyright (c) Erik Charlebois.
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+1. Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+3. The names of the author may not be used to endorse or promote
+   products derived from this software without specific prior written
+   permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGE.
diff --git a/Setup.hs b/Setup.hs
--- a/Setup.hs
+++ b/Setup.hs
@@ -1,6 +1,6 @@
-import Distribution.Simple
-import System.Cmd(system)
-
-main = defaultMainWithHooks $ simpleUserHooks { runTests = runElfTests }
-
-runElfTests a b pd lb = system "runhaskell -i./src ./tests/Test.hs" >> return ()
+import Distribution.Simple
+import System.Cmd(system)
+
+main = defaultMainWithHooks $ simpleUserHooks { runTests = runElfTests }
+
+runElfTests a b pd lb = system "runhaskell -i./src ./tests/Test.hs" >> return ()
diff --git a/dwarf.cabal b/dwarf.cabal
--- a/dwarf.cabal
+++ b/dwarf.cabal
@@ -1,20 +1,20 @@
-Name:          dwarf
-Version:       0.21
-License:       BSD3
-License-file:  LICENSE
-Category:      Data
-Author:        Erik Charlebois
-Copyright:     Erik Charlebois
-Maintainer:    Erik Charlebois <erikcharlebois@gmail.com>
-Stability:     unstable
-Cabal-Version: >= 1.2
-Build-Depends: base
-Build-Type:    Custom
-Synopsis:      Parser for DWARF debug format.
-Description:   Parser for DWARF debug format.
-Data-Files:    tests/Test.hs
-
-library
-    build-depends:   base >= 2 && < 5, bytestring, containers, binary
-    hs-source-dirs:  src
-    exposed-modules: Data.Dwarf
+Name:          dwarf
+Version:       0.22
+License:       BSD3
+License-file:  LICENSE
+Category:      Data
+Author:        Erik Charlebois
+Copyright:     Erik Charlebois
+Maintainer:    Erik Charlebois <erikcharlebois@gmail.com>
+Stability:     unstable
+Cabal-Version: >= 1.2
+Build-Depends: base
+Build-Type:    Custom
+Synopsis:      Parser for DWARF debug format.
+Description:   Parser for DWARF debug format.
+Data-Files:    tests/Test.hs
+
+library
+    build-depends:   base >= 2 && < 5, bytestring, containers, binary
+    hs-source-dirs:  src
+    exposed-modules: Data.Dwarf
diff --git a/src/Data/Dwarf.hs b/src/Data/Dwarf.hs
--- a/src/Data/Dwarf.hs
+++ b/src/Data/Dwarf.hs
@@ -1,6 +1,7 @@
 -- | Parses the DWARF 2 and DWARF 3 specifications at http://www.dwarfstd.org given
 -- the debug sections in ByteString form.
 module Data.Dwarf ( parseDwarfInfo
+                  , infoCompileUnit
                   , parseDwarfAranges
                   , parseDwarfPubnames
                   , parseDwarfPubtypes
@@ -295,9 +296,19 @@
         cu_values    <- mapM (getForm dr str_section cu_offset) cu_forms
         cu_ancestors <- if cu_has_children then getDieTree (Just cu_die_offset) Nothing abbrev_map dr str_section cu_offset else return []
         cu_siblings  <- getDieCus Nothing odr abbrev_section str_section
-        let cu_children = map dieId $ filter (\x -> if isJust (dieParent x) then fromJust (dieParent x) == cu_offset else False) cu_ancestors
+        let cu_children = map dieId $ filter (maybe False (== cu_die_offset) . dieParent) cu_ancestors
             cu_rsibling = if null cu_siblings then Nothing else Just $ dieId $ head cu_siblings
         return $ (DIE cu_die_offset Nothing cu_children cu_lsibling cu_rsibling cu_tag (zip cu_attrs cu_values) dr : cu_ancestors) ++ cu_siblings
+
+-- | Returns compilation unit id given the header offset into .debug_info
+infoCompileUnit  :: B.ByteString -- ^ Contents of .debug_info
+                 -> Word64 -- ^ Offset into .debug_info header
+                 -> Word64 -- ^ Offset of compile unit DIE.
+infoCompileUnit infoSection offset = do
+  case runGet getWord32be
+        (L.fromChunks [B.drop (fromIntegral offset) infoSection]) of
+    0xffffffff -> offset + 23
+    _ -> offset + 11
 
 -- | Parses the .debug_info section (as ByteString) using the .debug_abbrev and .debug_str sections.
 parseDwarfInfo :: Bool             -- ^ True for little endian target addresses. False for big endian.
diff --git a/tests/Test.hs b/tests/Test.hs
--- a/tests/Test.hs
+++ b/tests/Test.hs
@@ -1,12 +1,12 @@
-module Main where
-
-import Data.Dwarf
-import System.IO
-import Test.HUnit
-import Control.Monad
-import qualified Control.Exception as E
-import qualified Data.ByteString as B
-
-tests = TestList []
-
-main = runTestTT tests
+module Main where
+
+import Data.Dwarf
+import System.IO
+import Test.HUnit
+import Control.Monad
+import qualified Control.Exception as E
+import qualified Data.ByteString as B
+
+tests = TestList []
+
+main = runTestTT tests
