diff --git a/Data/VCD.hs b/Data/VCD.hs
--- a/Data/VCD.hs
+++ b/Data/VCD.hs
@@ -22,10 +22,11 @@
 import Data.Int
 import Data.IORef
 import Data.Word
-import Language.ImProve.Tree
 import System.IO
 import Text.ParserCombinators.Poly.Lazy
 import Text.Printf
+
+import Data.VCD.Tree
 
 -- | The VCDHandle keeps track of generation state and the output handle.
 data VCDHandle = VCDHandle
diff --git a/Data/VCD/Tree.hs b/Data/VCD/Tree.hs
new file mode 100644
--- /dev/null
+++ b/Data/VCD/Tree.hs
@@ -0,0 +1,46 @@
+-- | Building hierarchy from unstructured hierarchical paths.
+module Data.VCD.Tree
+  ( Tree (..)
+  , tree
+  ) where
+
+import Data.Function
+import Data.List
+
+data Tree a b
+  = Branch a [Tree a b]
+  | Leaf   a b
+
+tree :: (Eq a, Ord a) => (b -> [a]) -> [b] -> [Tree a b]
+tree path leaves = foldl mergeTrees [] [ singleTree (path leaf) leaf | leaf <- leaves ]
+
+label :: Tree a b -> a
+label (Branch a _) = a
+label (Leaf   a _) = a
+
+isBranch :: Tree a b -> Bool
+isBranch (Branch _ _) = True
+isBranch _ = False
+
+singleTree :: [a] -> b -> Tree a b
+singleTree [] _ = undefined
+singleTree [a] b = Leaf a b
+singleTree (a:b) c = Branch a [singleTree b c]
+
+mergeTrees :: (Eq a, Ord a) => [Tree a b] -> Tree a b -> [Tree a b]
+mergeTrees trees t@(Leaf _ _) = insertTree t trees
+mergeTrees trees t@(Branch n branches) = case find' (\ t -> isBranch t && label t == n) trees of
+    Nothing -> insertTree t trees
+    Just (Branch n trees1, trees2) -> insertTree (Branch n (foldl mergeTrees trees1 branches)) trees2
+    Just (Leaf _ _, _) -> undefined
+
+insertTree :: Ord a => Tree a b -> [Tree a b] -> [Tree a b]
+insertTree a b = insertBy (compare `on` label) a b
+
+find' :: (a -> Bool) -> [a] -> Maybe (a, [a])
+find' _ [] = Nothing
+find' f (a:b) | f a = Just (a, b)
+              | otherwise = do
+  (found, rest) <- find' f b
+  return (found, a : rest)
+
diff --git a/LICENSE b/LICENSE
--- a/LICENSE
+++ b/LICENSE
@@ -1,4 +1,4 @@
-Copyright (c) Tom Hawkins 2010
+Copyright (c) Tom Hawkins 2010 - 2012
 
 All rights reserved.
 
diff --git a/Setup.hs b/Setup.hs
new file mode 100644
--- /dev/null
+++ b/Setup.hs
@@ -0,0 +1,6 @@
+module Main (main) where
+
+import Distribution.Simple (defaultMain)
+
+main :: IO ()
+main = defaultMain
diff --git a/Setup.lhs b/Setup.lhs
deleted file mode 100644
--- a/Setup.lhs
+++ /dev/null
@@ -1,8 +0,0 @@
-#! /usr/bin/env runhaskell
-
-> module Main (main) where
->
-> import Distribution.Simple (defaultMain)
->
-> main :: IO ()
-> main = defaultMain
diff --git a/vcd.cabal b/vcd.cabal
--- a/vcd.cabal
+++ b/vcd.cabal
@@ -1,5 +1,5 @@
 name:    vcd
-version: 0.2.1
+version: 0.2.2
 
 category: Data, Hardware, Embedded
 
@@ -18,20 +18,20 @@
 homepage: http://tomahawkins.org
 
 build-type:    Simple
-cabal-version: >= 1.6
+cabal-version: >= 1.8
 
 library
-    build-depends:
-        base       >= 4.0   && < 5.0,
-        polyparse  >= 1.4   && < 1.6,
-        improve    >= 0.1.0 && < 0.2
+  build-depends:
+   base       >= 4.0 && < 5.0,
+   polyparse  >= 1.4 && < 2.0
 
-    exposed-modules:
-        Data.VCD
+  exposed-modules:
+    Data.VCD
+    Data.VCD.Tree
 
-    ghc-options:       -W
+  ghc-options: -W
 
 source-repository head
-    type:     git
-    location: git://github.com/tomahawkins/vcd.git
+  type:     git
+  location: git://github.com/tomahawkins/vcd.git
 
