diff --git a/CHANGELOG.md b/CHANGELOG.md
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,6 +1,10 @@
 # Changelog for [`clash-prelude` package](http://hackage.haskell.org/package/clash-prelude)
 
-## 0.10.5 *January 13th 2015*
+## 0.10.6 *February 10th 2016*
+* Fixes bugs:
+  * `CLaSH.Prelude.DataFlow.parNDF` is not lazy enough
+
+## 0.10.5 *January 13th 2016*
 * New features:
   * Add `readNew` to `CLaSH.Prelude.BlockRam`: create a read-after-write blockRAM from a read-before-write blockRAM.
   * `popCount` functions for `BitVector`, `Signed`, and `Unsigned` are now synthesisable.
diff --git a/LICENSE b/LICENSE
--- a/LICENSE
+++ b/LICENSE
@@ -1,4 +1,4 @@
-Copyright (c) 2013-2015, University of Twente
+Copyright (c) 2013-2016, University of Twente
 All rights reserved.
 
 Redistribution and use in source and binary forms, with or without
diff --git a/clash-prelude.cabal b/clash-prelude.cabal
--- a/clash-prelude.cabal
+++ b/clash-prelude.cabal
@@ -1,5 +1,5 @@
 Name:                 clash-prelude
-Version:              0.10.5
+Version:              0.10.6
 Synopsis:             CAES Language for Synchronous Hardware - Prelude library
 Description:
   CλaSH (pronounced ‘clash’) is a functional hardware description language that
@@ -45,7 +45,7 @@
 License-file:         LICENSE
 Author:               Christiaan Baaij
 Maintainer:           Christiaan Baaij <christiaan.baaij@gmail.com>
-Copyright:            Copyright © 2013-2015 University of Twente
+Copyright:            Copyright © 2013-2016 University of Twente
 Category:             Hardware
 Build-type:           Simple
 
@@ -118,6 +118,7 @@
                       CLaSH.Sized.BitVector
                       CLaSH.Sized.Fixed
                       CLaSH.Sized.Index
+                      CLaSH.Sized.RTree
                       CLaSH.Sized.Signed
                       CLaSH.Sized.Unsigned
                       CLaSH.Sized.Vector
@@ -157,7 +158,7 @@
                       integer-gmp               >= 0.5.1.0,
                       ghc-prim                  >= 0.3.1.0,
                       ghc-typelits-extra        >= 0.1,
-                      ghc-typelits-natnormalise >= 0.3,
+                      ghc-typelits-natnormalise >= 0.4.1,
                       lens                      >= 4.9,
                       QuickCheck                >= 2.7 && <2.9,
                       reflection                >= 2,
@@ -171,9 +172,6 @@
     -- See: https://github.com/clash-lang/clash-compiler/commit/721fcfa9198925661cd836668705f817bddaae3c
     -- as to why we need this.
     ghc-options:      -fcpr-off
-  -- Uncomment the 'else' branch once hackage recognises the DeriveLift extension
-  -- else
-  --   other-extensions: DeriveLift
 
   if flag(doclinks)
     CPP-Options:      -DDOCLINKS
diff --git a/src/CLaSH/Annotations/TopEntity.hs b/src/CLaSH/Annotations/TopEntity.hs
--- a/src/CLaSH/Annotations/TopEntity.hs
+++ b/src/CLaSH/Annotations/TopEntity.hs
@@ -1,11 +1,5 @@
-{-# LANGUAGE DeriveDataTypeable #-}
-
-{-# LANGUAGE Safe #-}
-
-{-# OPTIONS_HADDOCK show-extensions #-}
-
 {-|
-Copyright  :  (C) 2015, University of Twente
+Copyright  :  (C) 2015-2016, University of Twente
 License    :  BSD2 (see the file LICENSE)
 Maintainer :  Christiaan Baaij <christiaan.baaij@gmail.com>
 
@@ -167,6 +161,13 @@
 
 See the documentation of 'TopEntity' for the meaning of all its fields.
 -}
+
+{-# LANGUAGE DeriveDataTypeable #-}
+
+{-# LANGUAGE Safe #-}
+
+{-# OPTIONS_HADDOCK show-extensions #-}
+
 module CLaSH.Annotations.TopEntity
   ( -- * Data types
     TopEntity (..)
diff --git a/src/CLaSH/Class/BitPack.hs b/src/CLaSH/Class/BitPack.hs
--- a/src/CLaSH/Class/BitPack.hs
+++ b/src/CLaSH/Class/BitPack.hs
@@ -1,3 +1,9 @@
+{-|
+Copyright  :  (C) 2013-2016, University of Twente
+License    :  BSD2 (see the file LICENSE)
+Maintainer :  Christiaan Baaij <christiaan.baaij@gmail.com>
+-}
+
 {-# LANGUAGE DataKinds            #-}
 {-# LANGUAGE FlexibleContexts     #-}
 {-# LANGUAGE MagicHash            #-}
@@ -9,11 +15,6 @@
 
 {-# OPTIONS_HADDOCK show-extensions #-}
 
-{-|
-Copyright  :  (C) 2013-2015, University of Twente
-License    :  BSD2 (see the file LICENSE)
-Maintainer :  Christiaan Baaij <christiaan.baaij@gmail.com>
--}
 module CLaSH.Class.BitPack
   ( BitPack (..)
   , bitCoerce
diff --git a/src/CLaSH/Class/Num.hs b/src/CLaSH/Class/Num.hs
--- a/src/CLaSH/Class/Num.hs
+++ b/src/CLaSH/Class/Num.hs
@@ -1,3 +1,9 @@
+{-|
+Copyright  :  (C) 2013-2016, University of Twente
+License    :  BSD2 (see the file LICENSE)
+Maintainer :  Christiaan Baaij <christiaan.baaij@gmail.com>
+-}
+
 {-# LANGUAGE DataKinds             #-}
 {-# LANGUAGE MultiParamTypeClasses #-}
 {-# LANGUAGE TypeFamilies          #-}
@@ -6,11 +12,6 @@
 
 {-# OPTIONS_HADDOCK show-extensions #-}
 
-{-|
-Copyright  :  (C) 2013-2015, University of Twente
-License    :  BSD2 (see the file LICENSE)
-Maintainer :  Christiaan Baaij <christiaan.baaij@gmail.com>
--}
 module CLaSH.Class.Num
   ( -- * Arithmetic functions for arguments and results of different precision
     ExtendingNum (..)
diff --git a/src/CLaSH/Class/Resize.hs b/src/CLaSH/Class/Resize.hs
--- a/src/CLaSH/Class/Resize.hs
+++ b/src/CLaSH/Class/Resize.hs
@@ -1,3 +1,9 @@
+{-|
+Copyright  :  (C) 2013-2016, University of Twente
+License    :  BSD2 (see the file LICENSE)
+Maintainer :  Christiaan Baaij <christiaan.baaij@gmail.com>
+-}
+
 {-# LANGUAGE DataKinds        #-}
 {-# LANGUAGE FlexibleContexts #-}
 {-# LANGUAGE KindSignatures   #-}
@@ -7,11 +13,6 @@
 
 {-# OPTIONS_HADDOCK show-extensions #-}
 
-{-|
-Copyright  :  (C) 2013-2015, University of Twente
-License    :  BSD2 (see the file LICENSE)
-Maintainer :  Christiaan Baaij <christiaan.baaij@gmail.com>
--}
 module CLaSH.Class.Resize where
 
 import GHC.TypeLits (KnownNat, Nat, type (+))
diff --git a/src/CLaSH/Examples.hs b/src/CLaSH/Examples.hs
--- a/src/CLaSH/Examples.hs
+++ b/src/CLaSH/Examples.hs
@@ -1,11 +1,12 @@
+{-|
+Copyright : © Christiaan Baaij, 2015-2016
+Licence   : Creative Commons 4.0 (CC BY 4.0) (http://creativecommons.org/licenses/by/4.0/)
+-}
+
 {-# LANGUAGE NoImplicitPrelude, CPP, TemplateHaskell, DataKinds #-}
 {-# OPTIONS_GHC -fno-warn-unused-imports #-}
 {-# OPTIONS_GHC -fno-warn-unused-binds #-}
 
-{-|
-Copyright : © Christiaan Baaij, 2015
-Licence   : Creative Commons 4.0 (CC BY 4.0) (http://creativecommons.org/licenses/by/4.0/)
--}
 module CLaSH.Examples (
   -- * Decoders and Encoders
   -- $decoders_and_encoders
diff --git a/src/CLaSH/Prelude.hs b/src/CLaSH/Prelude.hs
--- a/src/CLaSH/Prelude.hs
+++ b/src/CLaSH/Prelude.hs
@@ -1,14 +1,5 @@
-{-# LANGUAGE CPP              #-}
-{-# LANGUAGE DataKinds        #-}
-{-# LANGUAGE FlexibleContexts #-}
-{-# LANGUAGE TypeOperators    #-}
-
-{-# LANGUAGE Unsafe #-}
-
-{-# OPTIONS_HADDOCK show-extensions #-}
-
 {-|
-  Copyright   :  (C) 2013-2015, University of Twente
+  Copyright   :  (C) 2013-2016, University of Twente
   License     :  BSD2 (see the file LICENSE)
   Maintainer  :  Christiaan Baaij <christiaan.baaij@gmail.com>
 
@@ -33,6 +24,16 @@
   library. A preliminary version of a tutorial can be found in "CLaSH.Tutorial".
   Some circuit examples can be found in "CLaSH.Examples".
 -}
+
+{-# LANGUAGE CPP              #-}
+{-# LANGUAGE DataKinds        #-}
+{-# LANGUAGE FlexibleContexts #-}
+{-# LANGUAGE TypeOperators    #-}
+
+{-# LANGUAGE Unsafe #-}
+
+{-# OPTIONS_HADDOCK show-extensions #-}
+
 module CLaSH.Prelude
   ( -- * Creating synchronous sequential circuits
     mealy
@@ -91,6 +92,8 @@
   , module CLaSH.Sized.Fixed
     -- *** Fixed size vectors
   , module CLaSH.Sized.Vector
+    -- *** Perfect depth trees
+  , module CLaSH.Sized.RTree
     -- ** Annotations
   , module CLaSH.Annotations.TopEntity
     -- ** Type-level natural numbers
@@ -157,6 +160,7 @@
 import CLaSH.Sized.BitVector
 import CLaSH.Sized.Fixed
 import CLaSH.Sized.Index
+import CLaSH.Sized.RTree
 import CLaSH.Sized.Signed
 import CLaSH.Sized.Unsigned
 import CLaSH.Sized.Vector
diff --git a/src/CLaSH/Prelude/BitIndex.hs b/src/CLaSH/Prelude/BitIndex.hs
--- a/src/CLaSH/Prelude/BitIndex.hs
+++ b/src/CLaSH/Prelude/BitIndex.hs
@@ -1,3 +1,9 @@
+{-|
+Copyright  :  (C) 2013-2016, University of Twente
+License    :  BSD2 (see the file LICENSE)
+Maintainer :  Christiaan Baaij <christiaan.baaij@gmail.com>
+-}
+
 {-# LANGUAGE DataKinds        #-}
 {-# LANGUAGE FlexibleContexts #-}
 {-# LANGUAGE MagicHash        #-}
@@ -8,11 +14,6 @@
 
 {-# OPTIONS_HADDOCK show-extensions #-}
 
-{-|
-Copyright  :  (C) 2013-2015, University of Twente
-License    :  BSD2 (see the file LICENSE)
-Maintainer :  Christiaan Baaij <christiaan.baaij@gmail.com>
--}
 module CLaSH.Prelude.BitIndex where
 
 import GHC.TypeLits                   (KnownNat, type (+), type (-))
diff --git a/src/CLaSH/Prelude/BitReduction.hs b/src/CLaSH/Prelude/BitReduction.hs
--- a/src/CLaSH/Prelude/BitReduction.hs
+++ b/src/CLaSH/Prelude/BitReduction.hs
@@ -1,3 +1,9 @@
+{-|
+Copyright  :  (C) 2013-2016, University of Twente
+License    :  BSD2 (see the file LICENSE)
+Maintainer :  Christiaan Baaij <christiaan.baaij@gmail.com>
+-}
+
 {-# LANGUAGE FlexibleContexts #-}
 {-# LANGUAGE MagicHash        #-}
 
@@ -5,11 +11,6 @@
 
 {-# OPTIONS_HADDOCK show-extensions #-}
 
-{-|
-Copyright  :  (C) 2013-2015, University of Twente
-License    :  BSD2 (see the file LICENSE)
-Maintainer :  Christiaan Baaij <christiaan.baaij@gmail.com>
--}
 module CLaSH.Prelude.BitReduction where
 
 import GHC.TypeLits                   (KnownNat)
diff --git a/src/CLaSH/Prelude/BlockRam.hs b/src/CLaSH/Prelude/BlockRam.hs
--- a/src/CLaSH/Prelude/BlockRam.hs
+++ b/src/CLaSH/Prelude/BlockRam.hs
@@ -1,14 +1,5 @@
-{-# LANGUAGE DataKinds        #-}
-{-# LANGUAGE FlexibleContexts #-}
-{-# LANGUAGE MagicHash        #-}
-{-# LANGUAGE TypeOperators    #-}
-
-{-# LANGUAGE Safe #-}
-
-{-# OPTIONS_HADDOCK show-extensions #-}
-
 {-|
-Copyright  :  (C) 2013-2015, University of Twente
+Copyright  :  (C) 2013-2016, University of Twente
 License    :  BSD2 (see the file LICENSE)
 Maintainer :  Christiaan Baaij <christiaan.baaij@gmail.com>
 
@@ -343,6 +334,16 @@
 This concludes the short introduction to using 'blockRam'.
 
 -}
+
+{-# LANGUAGE DataKinds        #-}
+{-# LANGUAGE FlexibleContexts #-}
+{-# LANGUAGE MagicHash        #-}
+{-# LANGUAGE TypeOperators    #-}
+
+{-# LANGUAGE Safe #-}
+
+{-# OPTIONS_HADDOCK show-extensions #-}
+
 module CLaSH.Prelude.BlockRam
   ( -- * BlockRAM synchronised to the system clock
     blockRam
diff --git a/src/CLaSH/Prelude/BlockRam/File.hs b/src/CLaSH/Prelude/BlockRam/File.hs
--- a/src/CLaSH/Prelude/BlockRam/File.hs
+++ b/src/CLaSH/Prelude/BlockRam/File.hs
@@ -1,15 +1,5 @@
-{-# LANGUAGE DataKinds           #-}
-{-# LANGUAGE FlexibleContexts    #-}
-{-# LANGUAGE MagicHash           #-}
-{-# LANGUAGE ScopedTypeVariables #-}
-{-# LANGUAGE TypeOperators       #-}
-
-{-# LANGUAGE Unsafe #-}
-
-{-# OPTIONS_HADDOCK show-extensions #-}
-
 {-|
-Copyright  :  (C) 2015, University of Twente
+Copyright  :  (C) 2015-2016, University of Twente
 License    :  BSD2 (see the file LICENSE)
 Maintainer :  Christiaan Baaij <christiaan.baaij@gmail.com>
 
@@ -72,6 +62,17 @@
 @
 
 -}
+
+{-# LANGUAGE DataKinds           #-}
+{-# LANGUAGE FlexibleContexts    #-}
+{-# LANGUAGE MagicHash           #-}
+{-# LANGUAGE ScopedTypeVariables #-}
+{-# LANGUAGE TypeOperators       #-}
+
+{-# LANGUAGE Unsafe #-}
+
+{-# OPTIONS_HADDOCK show-extensions #-}
+
 module CLaSH.Prelude.BlockRam.File
   ( -- * BlockRAM synchronised to the system clock
     blockRamFile
@@ -84,7 +85,6 @@
   , initMem
   )
 where
-
 
 import Control.Monad                (when)
 import Control.Monad.ST.Lazy        (ST,runST)
diff --git a/src/CLaSH/Prelude/DataFlow.hs b/src/CLaSH/Prelude/DataFlow.hs
--- a/src/CLaSH/Prelude/DataFlow.hs
+++ b/src/CLaSH/Prelude/DataFlow.hs
@@ -1,3 +1,11 @@
+{-|
+Copyright  :  (C) 2013-2016, University of Twente
+License    :  BSD2 (see the file LICENSE)
+Maintainer :  Christiaan Baaij <christiaan.baaij@gmail.com>
+
+Self-synchronising circuits based on data-flow principles.
+-}
+
 {-# LANGUAGE DataKinds             #-}
 {-# LANGUAGE FlexibleContexts      #-}
 {-# LANGUAGE FlexibleInstances     #-}
@@ -12,13 +20,6 @@
 {-# OPTIONS_GHC -fplugin GHC.TypeLits.Normalise #-}
 {-# OPTIONS_HADDOCK show-extensions #-}
 
-{-|
-Copyright  :  (C) 2013-2015, University of Twente
-License    :  BSD2 (see the file LICENSE)
-Maintainer :  Christiaan Baaij <christiaan.baaij@gmail.com>
-
-Self-synchronising circuits based on data-flow principles.
--}
 module CLaSH.Prelude.DataFlow
   ( -- * Data types
     DataFlow
@@ -293,7 +294,7 @@
             aVs' = unbundle' clk aVs
             bRs' = unbundle' clk bRs
             (bs,bVs,aRs) = unzip3 (zipWith (\k (a,b,r) -> df k a b r) fs
-                                  (zip3 as' aVs' bRs'))
+                                  (zip3 (lazyV as') (lazyV aVs') bRs'))
         in  (bundle' clk bs,bundle' clk bVs, bundle' clk aRs)
      )
 
diff --git a/src/CLaSH/Prelude/Explicit.hs b/src/CLaSH/Prelude/Explicit.hs
--- a/src/CLaSH/Prelude/Explicit.hs
+++ b/src/CLaSH/Prelude/Explicit.hs
@@ -1,14 +1,5 @@
-{-# LANGUAGE DataKinds        #-}
-{-# LANGUAGE FlexibleContexts #-}
-{-# LANGUAGE TypeOperators    #-}
-
-{-# LANGUAGE Unsafe #-}
-
-{-# OPTIONS_GHC -fno-warn-warnings-deprecations #-}
-{-# OPTIONS_HADDOCK show-extensions #-}
-
 {-|
-Copyright  :  (C) 2013-2015, University of Twente
+Copyright  :  (C) 2013-2016, University of Twente
 License    :  BSD2 (see the file LICENSE)
 Maintainer :  Christiaan Baaij <christiaan.baaij@gmail.com>
 
@@ -20,6 +11,16 @@
 look at "CLaSH.Signal.Explicit" to see how you can make multi-clock designs
 using explicitly clocked signals.
 -}
+
+{-# LANGUAGE DataKinds        #-}
+{-# LANGUAGE FlexibleContexts #-}
+{-# LANGUAGE TypeOperators    #-}
+
+{-# LANGUAGE Unsafe #-}
+
+{-# OPTIONS_GHC -fno-warn-warnings-deprecations #-}
+{-# OPTIONS_HADDOCK show-extensions #-}
+
 module CLaSH.Prelude.Explicit
   ( -- * Creating synchronous sequential circuits
     mealy'
diff --git a/src/CLaSH/Prelude/Explicit/Safe.hs b/src/CLaSH/Prelude/Explicit/Safe.hs
--- a/src/CLaSH/Prelude/Explicit/Safe.hs
+++ b/src/CLaSH/Prelude/Explicit/Safe.hs
@@ -1,13 +1,5 @@
-{-# LANGUAGE DataKinds        #-}
-{-# LANGUAGE FlexibleContexts #-}
-{-# LANGUAGE TypeOperators    #-}
-
-{-# LANGUAGE Safe #-}
-
-{-# OPTIONS_HADDOCK show-extensions #-}
-
 {-|
-Copyright  :  (C) 2013-2015, University of Twente
+Copyright  :  (C) 2013-2016, University of Twente
 License    :  BSD2 (see the file LICENSE)
 Maintainer :  Christiaan Baaij <christiaan.baaij@gmail.com>
 
@@ -21,6 +13,15 @@
 look at "CLaSH.Signal.Explicit" to see how you can make multi-clock designs
 using explicitly clocked signals.
 -}
+
+{-# LANGUAGE DataKinds        #-}
+{-# LANGUAGE FlexibleContexts #-}
+{-# LANGUAGE TypeOperators    #-}
+
+{-# LANGUAGE Safe #-}
+
+{-# OPTIONS_HADDOCK show-extensions #-}
+
 module CLaSH.Prelude.Explicit.Safe
   ( -- * Creating synchronous sequential circuits
     mealy'
diff --git a/src/CLaSH/Prelude/Mealy.hs b/src/CLaSH/Prelude/Mealy.hs
--- a/src/CLaSH/Prelude/Mealy.hs
+++ b/src/CLaSH/Prelude/Mealy.hs
@@ -1,7 +1,5 @@
-{-# LANGUAGE Safe #-}
-
 {-|
-  Copyright  :  (C) 2013-2015, University of Twente
+  Copyright  :  (C) 2013-2016, University of Twente
   License    :  BSD2 (see the file LICENSE)
   Maintainer :  Christiaan Baaij <christiaan.baaij@gmail.com>
 
@@ -11,6 +9,9 @@
   Mealy machines are strictly more expressive, but may impose stricter timing
   requirements.
 -}
+
+{-# LANGUAGE Safe #-}
+
 module CLaSH.Prelude.Mealy
   ( -- * Mealy machine synchronised to the system clock
     mealy
diff --git a/src/CLaSH/Prelude/Moore.hs b/src/CLaSH/Prelude/Moore.hs
--- a/src/CLaSH/Prelude/Moore.hs
+++ b/src/CLaSH/Prelude/Moore.hs
@@ -1,7 +1,5 @@
-{-# LANGUAGE Safe #-}
-
 {-|
-  Copyright  :  (C) 2013-2015, University of Twente
+  Copyright  :  (C) 2013-2016, University of Twente
   License    :  BSD2 (see the file LICENSE)
   Maintainer :  Christiaan Baaij <christiaan.baaij@gmail.com>
 
@@ -11,6 +9,9 @@
   Moore machines are strictly less expressive, but may impose laxer timing
   requirements.
 -}
+
+{-# LANGUAGE Safe #-}
+
 module CLaSH.Prelude.Moore
   ( -- * Moore machine synchronised to the system clock
     moore
diff --git a/src/CLaSH/Prelude/RAM.hs b/src/CLaSH/Prelude/RAM.hs
--- a/src/CLaSH/Prelude/RAM.hs
+++ b/src/CLaSH/Prelude/RAM.hs
@@ -1,3 +1,11 @@
+{-|
+Copyright  :  (C) 2015-2016, University of Twente
+License    :  BSD2 (see the file LICENSE)
+Maintainer :  Christiaan Baaij <christiaan.baaij@gmail.com>
+
+RAM primitives with a combinational read port.
+-}
+
 {-# LANGUAGE CPP                 #-}
 {-# LANGUAGE DataKinds           #-}
 {-# LANGUAGE FlexibleContexts    #-}
@@ -16,13 +24,6 @@
 
 {-# OPTIONS_HADDOCK show-extensions #-}
 
-{-|
-Copyright  :  (C) 2015, University of Twente
-License    :  BSD2 (see the file LICENSE)
-Maintainer :  Christiaan Baaij <christiaan.baaij@gmail.com>
-
-RAM primitives with a combinational read port.
--}
 module CLaSH.Prelude.RAM
   ( -- * RAM synchronised to the system clock
     asyncRam
diff --git a/src/CLaSH/Prelude/ROM.hs b/src/CLaSH/Prelude/ROM.hs
--- a/src/CLaSH/Prelude/ROM.hs
+++ b/src/CLaSH/Prelude/ROM.hs
@@ -1,3 +1,11 @@
+{-|
+Copyright  :  (C) 2015-2016, University of Twente
+License    :  BSD2 (see the file LICENSE)
+Maintainer :  Christiaan Baaij <christiaan.baaij@gmail.com>
+
+ROMs
+-}
+
 {-# LANGUAGE DataKinds        #-}
 {-# LANGUAGE FlexibleContexts #-}
 {-# LANGUAGE MagicHash        #-}
@@ -7,13 +15,6 @@
 
 {-# OPTIONS_HADDOCK show-extensions #-}
 
-{-|
-Copyright  :  (C) 2015, University of Twente
-License    :  BSD2 (see the file LICENSE)
-Maintainer :  Christiaan Baaij <christiaan.baaij@gmail.com>
-
-ROMs
--}
 module CLaSH.Prelude.ROM
   ( -- * Asynchronous ROM
     asyncRom
diff --git a/src/CLaSH/Prelude/ROM/File.hs b/src/CLaSH/Prelude/ROM/File.hs
--- a/src/CLaSH/Prelude/ROM/File.hs
+++ b/src/CLaSH/Prelude/ROM/File.hs
@@ -1,15 +1,5 @@
-{-# LANGUAGE DataKinds           #-}
-{-# LANGUAGE FlexibleContexts    #-}
-{-# LANGUAGE MagicHash           #-}
-{-# LANGUAGE ScopedTypeVariables #-}
-{-# LANGUAGE TypeOperators       #-}
-
-{-# LANGUAGE Unsafe #-}
-
-{-# OPTIONS_HADDOCK show-extensions #-}
-
 {-|
-Copyright  :  (C) 2015, University of Twente
+Copyright  :  (C) 2015-2016, University of Twente
 License    :  BSD2 (see the file LICENSE)
 Maintainer :  Christiaan Baaij <christiaan.baaij@gmail.com>
 
@@ -70,6 +60,17 @@
 [(1,2),(1,3)(1,-4)]
 @
 -}
+
+{-# LANGUAGE DataKinds           #-}
+{-# LANGUAGE FlexibleContexts    #-}
+{-# LANGUAGE MagicHash           #-}
+{-# LANGUAGE ScopedTypeVariables #-}
+{-# LANGUAGE TypeOperators       #-}
+
+{-# LANGUAGE Unsafe #-}
+
+{-# OPTIONS_HADDOCK show-extensions #-}
+
 module CLaSH.Prelude.ROM.File
   ( -- * Asynchronous ROM
     asyncRomFile
diff --git a/src/CLaSH/Prelude/Safe.hs b/src/CLaSH/Prelude/Safe.hs
--- a/src/CLaSH/Prelude/Safe.hs
+++ b/src/CLaSH/Prelude/Safe.hs
@@ -1,13 +1,5 @@
-{-# LANGUAGE DataKinds        #-}
-{-# LANGUAGE FlexibleContexts #-}
-{-# LANGUAGE TypeOperators    #-}
-
-{-# LANGUAGE Safe #-}
-
-{-# OPTIONS_HADDOCK show-extensions #-}
-
 {-|
-  Copyright   :  (C) 2013-2015, University of Twente
+  Copyright   :  (C) 2013-2016, University of Twente
   License     :  BSD2 (see the file LICENSE)
   Maintainer  :  Christiaan Baaij <christiaan.baaij@gmail.com>
 
@@ -34,6 +26,15 @@
   library. A preliminary version of a tutorial can be found in "CLaSH.Tutorial".
   Some circuit examples can be found in "CLaSH.Examples".
 -}
+
+{-# LANGUAGE DataKinds        #-}
+{-# LANGUAGE FlexibleContexts #-}
+{-# LANGUAGE TypeOperators    #-}
+
+{-# LANGUAGE Safe #-}
+
+{-# OPTIONS_HADDOCK show-extensions #-}
+
 module CLaSH.Prelude.Safe
   ( -- * Creating synchronous sequential circuits
     mealy
@@ -78,6 +79,8 @@
   , module CLaSH.Sized.Fixed
     -- *** Fixed size vectors
   , module CLaSH.Sized.Vector
+    -- *** Perfect depth trees
+  , module CLaSH.Sized.RTree
     -- ** Annotations
   , module CLaSH.Annotations.TopEntity
     -- ** Type-level natural numbers
@@ -133,6 +136,7 @@
 import CLaSH.Sized.BitVector
 import CLaSH.Sized.Fixed
 import CLaSH.Sized.Index
+import CLaSH.Sized.RTree
 import CLaSH.Sized.Signed
 import CLaSH.Sized.Unsigned
 import CLaSH.Sized.Vector
diff --git a/src/CLaSH/Prelude/Synchronizer.hs b/src/CLaSH/Prelude/Synchronizer.hs
--- a/src/CLaSH/Prelude/Synchronizer.hs
+++ b/src/CLaSH/Prelude/Synchronizer.hs
@@ -1,3 +1,11 @@
+{-|
+Copyright   :  (C) 2015-2016, University of Twente
+License     :  BSD2 (see the file LICENSE)
+Maintainer  :  Christiaan Baaij <christiaan.baaij@gmail.com>
+
+Synchronizer circuits for safe clock domain crossings
+-}
+
 {-# LANGUAGE DataKinds             #-}
 {-# LANGUAGE FlexibleContexts      #-}
 {-# LANGUAGE PartialTypeSignatures #-}
@@ -9,13 +17,6 @@
 {-# OPTIONS_GHC -fno-warn-partial-type-signatures #-}
 {-# OPTIONS_HADDOCK show-extensions #-}
 
-{-|
-Copyright   :  (C) 2015, University of Twente
-License     :  BSD2 (see the file LICENSE)
-Maintainer  :  Christiaan Baaij <christiaan.baaij@gmail.com>
-
-Synchronizer circuits for safe clock domain crossings
--}
 module CLaSH.Prelude.Synchronizer
   ( -- * Bit-synchronizers
     dualFlipFlopSynchronizer
diff --git a/src/CLaSH/Prelude/Testbench.hs b/src/CLaSH/Prelude/Testbench.hs
--- a/src/CLaSH/Prelude/Testbench.hs
+++ b/src/CLaSH/Prelude/Testbench.hs
@@ -1,14 +1,15 @@
+{-|
+Copyright  :  (C) 2013-2016, University of Twente
+License    :  BSD2 (see the file LICENSE)
+Maintainer :  Christiaan Baaij <christiaan.baaij@gmail.com>
+-}
+
 {-# LANGUAGE ScopedTypeVariables #-}
 
 {-# LANGUAGE Unsafe #-}
 
 {-# OPTIONS_HADDOCK show-extensions #-}
 
-{-|
-Copyright  :  (C) 2013-2015, University of Twente
-License    :  BSD2 (see the file LICENSE)
-Maintainer :  Christiaan Baaij <christiaan.baaij@gmail.com>
--}
 module CLaSH.Prelude.Testbench
   ( -- * Testbench functions for circuits synchronised to the system slock
     assert
diff --git a/src/CLaSH/Promoted/Nat.hs b/src/CLaSH/Promoted/Nat.hs
--- a/src/CLaSH/Promoted/Nat.hs
+++ b/src/CLaSH/Promoted/Nat.hs
@@ -1,3 +1,9 @@
+{-|
+Copyright  :  (C) 2013-2016, University of Twente
+License    :  BSD2 (see the file LICENSE)
+Maintainer :  Christiaan Baaij <christiaan.baaij@gmail.com>
+-}
+
 {-# LANGUAGE DataKinds           #-}
 {-# LANGUAGE FlexibleContexts    #-}
 {-# LANGUAGE GADTs               #-}
@@ -10,11 +16,6 @@
 {-# OPTIONS_GHC -fplugin GHC.TypeLits.Normalise #-}
 {-# OPTIONS_HADDOCK show-extensions #-}
 
-{-|
-Copyright  :  (C) 2013-2015, University of Twente
-License    :  BSD2 (see the file LICENSE)
-Maintainer :  Christiaan Baaij <christiaan.baaij@gmail.com>
--}
 module CLaSH.Promoted.Nat
   ( SNat (..), snat, withSNat, snatToInteger, addSNat, subSNat, mulSNat, powSNat
   , UNat (..), toUNat, addUNat, multUNat, powUNat
diff --git a/src/CLaSH/Promoted/Nat/Literals.hs b/src/CLaSH/Promoted/Nat/Literals.hs
--- a/src/CLaSH/Promoted/Nat/Literals.hs
+++ b/src/CLaSH/Promoted/Nat/Literals.hs
@@ -1,12 +1,5 @@
-{-# LANGUAGE TemplateHaskell #-}
-{-# LANGUAGE DataKinds       #-}
-
-{-# LANGUAGE Trustworthy #-}
-
-{-# OPTIONS_HADDOCK show-extensions #-}
-
 {-|
-Copyright  :  (C) 2013-2015, University of Twente
+Copyright  :  (C) 2013-2016, University of Twente
 License    :  BSD2 (see the file LICENSE)
 Maintainer :  Christiaan Baaij <christiaan.baaij@gmail.com>
 
@@ -24,6 +17,14 @@
 
 You can generate more 'SNat' literals using 'decLiteralsD' from "CLaSH.Promoted.Nat.TH"
 -}
+
+{-# LANGUAGE TemplateHaskell #-}
+{-# LANGUAGE DataKinds       #-}
+
+{-# LANGUAGE Trustworthy #-}
+
+{-# OPTIONS_HADDOCK show-extensions #-}
+
 module CLaSH.Promoted.Nat.Literals where
 
 import CLaSH.Promoted.Nat.TH
diff --git a/src/CLaSH/Promoted/Nat/TH.hs b/src/CLaSH/Promoted/Nat/TH.hs
--- a/src/CLaSH/Promoted/Nat/TH.hs
+++ b/src/CLaSH/Promoted/Nat/TH.hs
@@ -1,14 +1,15 @@
+{-|
+Copyright  :  (C) 2013-2016, University of Twente
+License    :  BSD2 (see the file LICENSE)
+Maintainer :  Christiaan Baaij <christiaan.baaij@gmail.com>
+-}
+
 {-# LANGUAGE TemplateHaskell #-}
 
 {-# LANGUAGE Trustworthy #-}
 
 {-# OPTIONS_HADDOCK show-extensions #-}
 
-{-|
-Copyright  :  (C) 2013-2015, University of Twente
-License    :  BSD2 (see the file LICENSE)
-Maintainer :  Christiaan Baaij <christiaan.baaij@gmail.com>
--}
 module CLaSH.Promoted.Nat.TH
   ( -- * Declare a single @d\<N\>@ literal
     decLiteralD
diff --git a/src/CLaSH/Promoted/Nat/Unsafe.hs b/src/CLaSH/Promoted/Nat/Unsafe.hs
--- a/src/CLaSH/Promoted/Nat/Unsafe.hs
+++ b/src/CLaSH/Promoted/Nat/Unsafe.hs
@@ -1,10 +1,11 @@
-{-# LANGUAGE Unsafe #-}
-
 {-|
-Copyright  :  (C) 2015, University of Twente
+Copyright  :  (C) 2015-2016, University of Twente
 License    :  BSD2 (see the file LICENSE)
 Maintainer :  Christiaan Baaij <christiaan.baaij@gmail.com>
 -}
+
+{-# LANGUAGE Unsafe #-}
+
 module CLaSH.Promoted.Nat.Unsafe
   (unsafeSNat)
 where
diff --git a/src/CLaSH/Promoted/Ord.hs b/src/CLaSH/Promoted/Ord.hs
--- a/src/CLaSH/Promoted/Ord.hs
+++ b/src/CLaSH/Promoted/Ord.hs
@@ -1,3 +1,9 @@
+{-|
+Copyright  :  (C) 2013-2016, University of Twente
+License    :  BSD2 (see the file LICENSE)
+Maintainer :  Christiaan Baaij <christiaan.baaij@gmail.com>
+-}
+
 {-# LANGUAGE DataKinds            #-}
 {-# LANGUAGE TypeFamilies         #-}
 {-# LANGUAGE TypeOperators        #-}
@@ -7,11 +13,6 @@
 
 {-# OPTIONS_HADDOCK show-extensions #-}
 
-{-|
-Copyright  :  (C) 2013-2015, University of Twente
-License    :  BSD2 (see the file LICENSE)
-Maintainer :  Christiaan Baaij <christiaan.baaij@gmail.com>
--}
 module CLaSH.Promoted.Ord where
 
 import Data.Type.Bool
diff --git a/src/CLaSH/Promoted/Symbol.hs b/src/CLaSH/Promoted/Symbol.hs
--- a/src/CLaSH/Promoted/Symbol.hs
+++ b/src/CLaSH/Promoted/Symbol.hs
@@ -1,3 +1,9 @@
+{-|
+Copyright  :  (C) 2013-2016, University of Twente
+License    :  BSD2 (see the file LICENSE)
+Maintainer :  Christiaan Baaij <christiaan.baaij@gmail.com>
+-}
+
 {-# LANGUAGE DataKinds      #-}
 {-# LANGUAGE GADTs          #-}
 {-# LANGUAGE KindSignatures #-}
@@ -6,11 +12,6 @@
 
 {-# OPTIONS_HADDOCK show-extensions #-}
 
-{-|
-Copyright  :  (C) 2013-2015, University of Twente
-License    :  BSD2 (see the file LICENSE)
-Maintainer :  Christiaan Baaij <christiaan.baaij@gmail.com>
--}
 module CLaSH.Promoted.Symbol
   (SSymbol (..), ssymbol, ssymbolToString)
 where
diff --git a/src/CLaSH/Signal.hs b/src/CLaSH/Signal.hs
--- a/src/CLaSH/Signal.hs
+++ b/src/CLaSH/Signal.hs
@@ -1,3 +1,9 @@
+{-|
+Copyright  :  (C) 2013-2016, University of Twente
+License    :  BSD2 (see the file LICENSE)
+Maintainer :  Christiaan Baaij <christiaan.baaij@gmail.com>
+-}
+
 {-# LANGUAGE MagicHash #-}
 
 {-# LANGUAGE Trustworthy #-}
@@ -5,11 +11,6 @@
 {-# OPTIONS_GHC -fno-warn-unused-imports #-}
 {-# OPTIONS_HADDOCK show-extensions #-}
 
-{-|
-Copyright  :  (C) 2013-2015, University of Twente
-License    :  BSD2 (see the file LICENSE)
-Maintainer :  Christiaan Baaij <christiaan.baaij@gmail.com>
--}
 module CLaSH.Signal
   ( -- * Implicitly clocked synchronous signal
     Signal
diff --git a/src/CLaSH/Signal/Bundle.hs b/src/CLaSH/Signal/Bundle.hs
--- a/src/CLaSH/Signal/Bundle.hs
+++ b/src/CLaSH/Signal/Bundle.hs
@@ -1,3 +1,11 @@
+{-|
+Copyright  :  (C) 2013-2016, University of Twente
+License    :  BSD2 (see the file LICENSE)
+Maintainer :  Christiaan Baaij <christiaan.baaij@gmail.com>
+
+The Product/Signal isomorphism
+-}
+
 {-# LANGUAGE DataKinds         #-}
 {-# LANGUAGE DefaultSignatures #-}
 {-# LANGUAGE KindSignatures    #-}
@@ -8,13 +16,6 @@
 
 {-# OPTIONS_HADDOCK show-extensions #-}
 
-{-|
-Copyright  :  (C) 2013-2015, University of Twente
-License    :  BSD2 (see the file LICENSE)
-Maintainer :  Christiaan Baaij <christiaan.baaij@gmail.com>
-
-The Product/Signal isomorphism
--}
 module CLaSH.Signal.Bundle
   ( Bundle (..)
   )
diff --git a/src/CLaSH/Signal/Delayed.hs b/src/CLaSH/Signal/Delayed.hs
--- a/src/CLaSH/Signal/Delayed.hs
+++ b/src/CLaSH/Signal/Delayed.hs
@@ -1,3 +1,9 @@
+{-|
+Copyright  :  (C) 2013-2016, University of Twente
+License    :  BSD2 (see the file LICENSE)
+Maintainer :  Christiaan Baaij <christiaan.baaij@gmail.com>
+-}
+
 {-# LANGUAGE CPP                        #-}
 {-# LANGUAGE DataKinds                  #-}
 #if __GLASGOW_HASKELL__ > 710
@@ -18,11 +24,6 @@
 {-# OPTIONS_GHC -fplugin GHC.TypeLits.Normalise #-}
 {-# OPTIONS_HADDOCK show-extensions #-}
 
-{-|
-Copyright  :  (C) 2013-2015, University of Twente
-License    :  BSD2 (see the file LICENSE)
-Maintainer :  Christiaan Baaij <christiaan.baaij@gmail.com>
--}
 module CLaSH.Signal.Delayed
   ( -- * Delay-annotated synchronous signals
     DSignal
diff --git a/src/CLaSH/Signal/Explicit.hs b/src/CLaSH/Signal/Explicit.hs
--- a/src/CLaSH/Signal/Explicit.hs
+++ b/src/CLaSH/Signal/Explicit.hs
@@ -1,3 +1,9 @@
+{-|
+Copyright  :  (C) 2013-2016, University of Twente
+License    :  BSD2 (see the file LICENSE)
+Maintainer :  Christiaan Baaij <christiaan.baaij@gmail.com>
+-}
+
 {-# LANGUAGE DataKinds #-}
 {-# LANGUAGE GADTs     #-}
 {-# LANGUAGE MagicHash #-}
@@ -6,11 +12,6 @@
 
 {-# OPTIONS_HADDOCK show-extensions #-}
 
-{-|
-Copyright  :  (C) 2013-2015, University of Twente
-License    :  BSD2 (see the file LICENSE)
-Maintainer :  Christiaan Baaij <christiaan.baaij@gmail.com>
--}
 module CLaSH.Signal.Explicit
   ( -- * Explicitly clocked synchronous signal
     -- $relativeclocks
diff --git a/src/CLaSH/Signal/Internal.hs b/src/CLaSH/Signal/Internal.hs
--- a/src/CLaSH/Signal/Internal.hs
+++ b/src/CLaSH/Signal/Internal.hs
@@ -1,3 +1,9 @@
+{-|
+Copyright  :  (C) 2013-2016, University of Twente
+License    :  BSD2 (see the file LICENSE)
+Maintainer :  Christiaan Baaij <christiaan.baaij@gmail.com>
+-}
+
 {-# LANGUAGE CPP                   #-}
 {-# LANGUAGE DataKinds             #-}
 {-# LANGUAGE FlexibleInstances     #-}
@@ -19,11 +25,6 @@
 
 {-# OPTIONS_HADDOCK show-extensions #-}
 
-{-|
-Copyright  :  (C) 2013-2015, University of Twente
-License    :  BSD2 (see the file LICENSE)
-Maintainer :  Christiaan Baaij <christiaan.baaij@gmail.com>
--}
 module CLaSH.Signal.Internal
   ( -- * Datatypes
     Clock (..)
diff --git a/src/CLaSH/Sized/BitVector.hs b/src/CLaSH/Sized/BitVector.hs
--- a/src/CLaSH/Sized/BitVector.hs
+++ b/src/CLaSH/Sized/BitVector.hs
@@ -1,14 +1,15 @@
+{-|
+Copyright  :  (C) 2013-2016, University of Twente
+License    :  BSD2 (see the file LICENSE)
+Maintainer :  Christiaan Baaij <christiaan.baaij@gmail.com>
+-}
+
 {-# LANGUAGE MagicHash #-}
 
 {-# LANGUAGE Trustworthy #-}
 
 {-# OPTIONS_HADDOCK show-extensions #-}
 
-{-|
-Copyright  :  (C) 2013-2015, University of Twente
-License    :  BSD2 (see the file LICENSE)
-Maintainer :  Christiaan Baaij <christiaan.baaij@gmail.com>
--}
 module CLaSH.Sized.BitVector
   ( -- * Datatypes
     BitVector
diff --git a/src/CLaSH/Sized/Fixed.hs b/src/CLaSH/Sized/Fixed.hs
--- a/src/CLaSH/Sized/Fixed.hs
+++ b/src/CLaSH/Sized/Fixed.hs
@@ -1,22 +1,5 @@
-{-# LANGUAGE ConstraintKinds            #-}
-{-# LANGUAGE DataKinds                  #-}
-{-# LANGUAGE FlexibleContexts           #-}
-{-# LANGUAGE GeneralizedNewtypeDeriving #-}
-{-# LANGUAGE KindSignatures             #-}
-{-# LANGUAGE MultiParamTypeClasses      #-}
-{-# LANGUAGE ScopedTypeVariables        #-}
-{-# LANGUAGE StandaloneDeriving         #-}
-{-# LANGUAGE TemplateHaskell            #-}
-{-# LANGUAGE TypeOperators              #-}
-{-# LANGUAGE TypeFamilies               #-}
-{-# LANGUAGE UndecidableInstances       #-}
-
-{-# LANGUAGE Trustworthy #-}
-
-{-# OPTIONS_HADDOCK show-extensions #-}
-
 {-|
-Copyright  :  (C) 2013-2015, University of Twente
+Copyright  :  (C) 2013-2016, University of Twente
 License    :  BSD2 (see the file LICENSE)
 Maintainer :  Christiaan Baaij <christiaan.baaij@gmail.com>
 
@@ -38,6 +21,24 @@
 * Truncation for positive numbers effectively results in: round towards zero.
 * Truncation for negative numbers effectively results in: round towards -infinity.
 -}
+
+{-# LANGUAGE ConstraintKinds            #-}
+{-# LANGUAGE DataKinds                  #-}
+{-# LANGUAGE FlexibleContexts           #-}
+{-# LANGUAGE GeneralizedNewtypeDeriving #-}
+{-# LANGUAGE KindSignatures             #-}
+{-# LANGUAGE MultiParamTypeClasses      #-}
+{-# LANGUAGE ScopedTypeVariables        #-}
+{-# LANGUAGE StandaloneDeriving         #-}
+{-# LANGUAGE TemplateHaskell            #-}
+{-# LANGUAGE TypeOperators              #-}
+{-# LANGUAGE TypeFamilies               #-}
+{-# LANGUAGE UndecidableInstances       #-}
+
+{-# LANGUAGE Trustworthy #-}
+
+{-# OPTIONS_HADDOCK show-extensions #-}
+
 module CLaSH.Sized.Fixed
   ( -- * 'SFixed': 'Signed' 'Fixed' point numbers
     SFixed, sf, unSF
diff --git a/src/CLaSH/Sized/Index.hs b/src/CLaSH/Sized/Index.hs
--- a/src/CLaSH/Sized/Index.hs
+++ b/src/CLaSH/Sized/Index.hs
@@ -1,3 +1,9 @@
+{-|
+Copyright  :  (C) 2013-2016, University of Twente
+License    :  BSD2 (see the file LICENSE)
+Maintainer :  Christiaan Baaij <christiaan.baaij@gmail.com>
+-}
+
 {-# LANGUAGE DataKinds        #-}
 {-# LANGUAGE FlexibleContexts #-}
 {-# LANGUAGE MagicHash        #-}
@@ -9,11 +15,6 @@
 {-# OPTIONS_GHC -fno-warn-unused-imports #-}
 {-# OPTIONS_HADDOCK show-extensions #-}
 
-{-|
-Copyright  :  (C) 2013-2015, University of Twente
-License    :  BSD2 (see the file LICENSE)
-Maintainer :  Christiaan Baaij <christiaan.baaij@gmail.com>
--}
 module CLaSH.Sized.Index
   (Index, bv2i)
 where
diff --git a/src/CLaSH/Sized/Internal/BitVector.hs b/src/CLaSH/Sized/Internal/BitVector.hs
--- a/src/CLaSH/Sized/Internal/BitVector.hs
+++ b/src/CLaSH/Sized/Internal/BitVector.hs
@@ -1,3 +1,9 @@
+{-|
+Copyright  :  (C) 2013-2016, University of Twente
+License    :  BSD2 (see the file LICENSE)
+Maintainer :  Christiaan Baaij <christiaan.baaij@gmail.com>
+-}
+
 {-# LANGUAGE DataKinds             #-}
 {-# LANGUAGE FlexibleContexts      #-}
 {-# LANGUAGE KindSignatures        #-}
@@ -12,11 +18,6 @@
 
 {-# OPTIONS_HADDOCK show-extensions #-}
 
-{-|
-Copyright  :  (C) 2013-2015, University of Twente
-License    :  BSD2 (see the file LICENSE)
-Maintainer :  Christiaan Baaij <christiaan.baaij@gmail.com>
--}
 module CLaSH.Sized.Internal.BitVector
   ( -- * Datatypes
     BitVector (..)
diff --git a/src/CLaSH/Sized/Internal/BitVector.hs-boot b/src/CLaSH/Sized/Internal/BitVector.hs-boot
--- a/src/CLaSH/Sized/Internal/BitVector.hs-boot
+++ b/src/CLaSH/Sized/Internal/BitVector.hs-boot
@@ -1,3 +1,9 @@
+{-|
+Copyright  :  (C) 2015-2016, University of Twente
+License    :  BSD2 (see the file LICENSE)
+Maintainer :  Christiaan Baaij <christiaan.baaij@gmail.com>
+-}
+
 {-# LANGUAGE DataKinds       #-}
 {-# LANGUAGE KindSignatures  #-}
 {-# LANGUAGE RoleAnnotations #-}
diff --git a/src/CLaSH/Sized/Internal/Index.hs b/src/CLaSH/Sized/Internal/Index.hs
--- a/src/CLaSH/Sized/Internal/Index.hs
+++ b/src/CLaSH/Sized/Internal/Index.hs
@@ -1,3 +1,9 @@
+{-|
+Copyright  :  (C) 2013-2016, University of Twente
+License    :  BSD2 (see the file LICENSE)
+Maintainer :  Christiaan Baaij <christiaan.baaij@gmail.com>
+-}
+
 {-# LANGUAGE DataKinds             #-}
 {-# LANGUAGE KindSignatures        #-}
 {-# LANGUAGE MagicHash             #-}
@@ -11,11 +17,6 @@
 
 {-# OPTIONS_HADDOCK show-extensions #-}
 
-{-|
-Copyright  :  (C) 2013-2015, University of Twente
-License    :  BSD2 (see the file LICENSE)
-Maintainer :  Christiaan Baaij <christiaan.baaij@gmail.com>
--}
 module CLaSH.Sized.Internal.Index
   ( -- * Datatypes
     Index (..)
diff --git a/src/CLaSH/Sized/Internal/Index.hs-boot b/src/CLaSH/Sized/Internal/Index.hs-boot
--- a/src/CLaSH/Sized/Internal/Index.hs-boot
+++ b/src/CLaSH/Sized/Internal/Index.hs-boot
@@ -1,3 +1,9 @@
+{-|
+Copyright  :  (C) 2015-2016, University of Twente
+License    :  BSD2 (see the file LICENSE)
+Maintainer :  Christiaan Baaij <christiaan.baaij@gmail.com>
+-}
+
 {-# LANGUAGE DataKinds       #-}
 {-# LANGUAGE KindSignatures  #-}
 {-# LANGUAGE RoleAnnotations #-}
diff --git a/src/CLaSH/Sized/Internal/Signed.hs b/src/CLaSH/Sized/Internal/Signed.hs
--- a/src/CLaSH/Sized/Internal/Signed.hs
+++ b/src/CLaSH/Sized/Internal/Signed.hs
@@ -1,3 +1,9 @@
+{-|
+Copyright  :  (C) 2013-2016, University of Twente
+License    :  BSD2 (see the file LICENSE)
+Maintainer :  Christiaan Baaij <christiaan.baaij@gmail.com>
+-}
+
 {-# LANGUAGE DataKinds             #-}
 {-# LANGUAGE FlexibleContexts      #-}
 {-# LANGUAGE KindSignatures        #-}
@@ -12,11 +18,6 @@
 
 {-# OPTIONS_HADDOCK show-extensions #-}
 
-{-|
-Copyright  :  (C) 2013-2015, University of Twente
-License    :  BSD2 (see the file LICENSE)
-Maintainer :  Christiaan Baaij <christiaan.baaij@gmail.com>
--}
 module CLaSH.Sized.Internal.Signed
   ( -- * Datatypes
     Signed (..)
diff --git a/src/CLaSH/Sized/Internal/Unsigned.hs b/src/CLaSH/Sized/Internal/Unsigned.hs
--- a/src/CLaSH/Sized/Internal/Unsigned.hs
+++ b/src/CLaSH/Sized/Internal/Unsigned.hs
@@ -1,3 +1,9 @@
+{-|
+Copyright  :  (C) 2013-2016, University of Twente
+License    :  BSD2 (see the file LICENSE)
+Maintainer :  Christiaan Baaij <christiaan.baaij@gmail.com>
+-}
+
 {-# LANGUAGE DataKinds                  #-}
 {-# LANGUAGE FlexibleContexts           #-}
 {-# LANGUAGE MagicHash                  #-}
@@ -11,11 +17,6 @@
 
 {-# OPTIONS_HADDOCK show-extensions #-}
 
-{-|
-Copyright  :  (C) 2013-2015, University of Twente
-License    :  BSD2 (see the file LICENSE)
-Maintainer :  Christiaan Baaij <christiaan.baaij@gmail.com>
--}
 module CLaSH.Sized.Internal.Unsigned
   ( -- * Datatypes
     Unsigned (..)
diff --git a/src/CLaSH/Sized/RTree.hs b/src/CLaSH/Sized/RTree.hs
new file mode 100644
--- /dev/null
+++ b/src/CLaSH/Sized/RTree.hs
@@ -0,0 +1,38 @@
+{-|
+Copyright  :  (C) 2016, University of Twente
+License    :  BSD2 (see the file LICENSE)
+Maintainer :  Christiaan Baaij <christiaan.baaij@gmail.com>
+-}
+
+{-# LANGUAGE DataKinds, TypeOperators, GADTs, ScopedTypeVariables,
+             KindSignatures, RankNTypes #-}
+
+{-# LANGUAGE Trustworthy #-}
+
+{-# OPTIONS_GHC -fplugin GHC.TypeLits.Normalise #-}
+
+module CLaSH.Sized.RTree where
+
+import Data.Singletons.Prelude     (TyFun,type ($))
+import Data.Proxy                  (Proxy (..))
+import GHC.TypeLits                (KnownNat, Nat, type (+))
+
+import CLaSH.Promoted.Nat          (SNat, snat, subSNat)
+import CLaSH.Promoted.Nat.Literals (d1)
+
+data RTree :: Nat -> * -> * where
+  LR :: a -> RTree 0 a
+  BR :: RTree n a -> RTree n a -> RTree (n+1) a
+
+tfold :: forall p k a . KnownNat k
+      => Proxy (p :: TyFun Nat * -> *)
+      -> (a -> (p $ 0))
+      -> (forall l . SNat l -> (p $ l) -> (p $ l) -> (p $ (l+1)))
+      -> RTree k a
+      -> (p $ k)
+tfold _ f g = go snat
+  where
+    go :: SNat m -> RTree m a -> (p $ m)
+    go _  (LR a)   = f a
+    go sn (BR l r) = let sn' = sn `subSNat` d1
+                     in  g sn' (go sn' l) (go sn' r)
diff --git a/src/CLaSH/Sized/Signed.hs b/src/CLaSH/Sized/Signed.hs
--- a/src/CLaSH/Sized/Signed.hs
+++ b/src/CLaSH/Sized/Signed.hs
@@ -1,9 +1,11 @@
-{-# LANGUAGE Trustworthy #-}
 {-|
-Copyright  :  (C) 2013-2015, University of Twente
+Copyright  :  (C) 2013-2016, University of Twente
 License    :  BSD2 (see the file LICENSE)
 Maintainer :  Christiaan Baaij <christiaan.baaij@gmail.com>
 -}
+
+{-# LANGUAGE Trustworthy #-}
+
 module CLaSH.Sized.Signed
   ( Signed
   )
diff --git a/src/CLaSH/Sized/Unsigned.hs b/src/CLaSH/Sized/Unsigned.hs
--- a/src/CLaSH/Sized/Unsigned.hs
+++ b/src/CLaSH/Sized/Unsigned.hs
@@ -1,9 +1,11 @@
-{-# LANGUAGE Trustworthy #-}
 {-|
-Copyright  :  (C) 2013-2015, University of Twente
+Copyright  :  (C) 2013-2016, University of Twente
 License    :  BSD2 (see the file LICENSE)
 Maintainer :  Christiaan Baaij <christiaan.baaij@gmail.com>
 -}
+
+{-# LANGUAGE Trustworthy #-}
+
 module CLaSH.Sized.Unsigned
   (Unsigned)
 where
diff --git a/src/CLaSH/Sized/Vector.hs b/src/CLaSH/Sized/Vector.hs
--- a/src/CLaSH/Sized/Vector.hs
+++ b/src/CLaSH/Sized/Vector.hs
@@ -1,3 +1,9 @@
+{-|
+Copyright  :  (C) 2013-2016, University of Twente
+License    :  BSD2 (see the file LICENSE)
+Maintainer :  Christiaan Baaij <christiaan.baaij@gmail.com>
+-}
+
 {-# LANGUAGE BangPatterns         #-}
 {-# LANGUAGE DataKinds            #-}
 {-# LANGUAGE FlexibleContexts     #-}
@@ -20,11 +26,6 @@
 {-# OPTIONS_GHC -fno-warn-incomplete-patterns #-}
 {-# OPTIONS_HADDOCK show-extensions #-}
 
-{-|
-Copyright  :  (C) 2013-2015, University of Twente
-License    :  BSD2 (see the file LICENSE)
-Maintainer :  Christiaan Baaij <christiaan.baaij@gmail.com>
--}
 module CLaSH.Sized.Vector
   ( -- * 'Vec'tor data type
     Vec(..)
diff --git a/src/CLaSH/Sized/Vector.hs-boot b/src/CLaSH/Sized/Vector.hs-boot
--- a/src/CLaSH/Sized/Vector.hs-boot
+++ b/src/CLaSH/Sized/Vector.hs-boot
@@ -1,3 +1,9 @@
+{-|
+Copyright  :  (C) 2015-2016, University of Twente
+License    :  BSD2 (see the file LICENSE)
+Maintainer :  Christiaan Baaij <christiaan.baaij@gmail.com>
+-}
+
 {-# LANGUAGE DataKinds       #-}
 {-# LANGUAGE GADTs           #-}
 {-# LANGUAGE KindSignatures  #-}
diff --git a/src/CLaSH/Tutorial.hs b/src/CLaSH/Tutorial.hs
--- a/src/CLaSH/Tutorial.hs
+++ b/src/CLaSH/Tutorial.hs
@@ -1,10 +1,11 @@
-{-# LANGUAGE NoImplicitPrelude, MagicHash #-}
-{-# OPTIONS_GHC -fno-warn-unused-imports #-}
-
 {-|
-Copyright : © Christiaan Baaij, 2014-2015
+Copyright : © Christiaan Baaij, 2014-2016
 Licence   : Creative Commons 4.0 (CC BY 4.0) (http://creativecommons.org/licenses/by/4.0/)
 -}
+
+{-# LANGUAGE NoImplicitPrelude, MagicHash #-}
+{-# OPTIONS_GHC -fno-warn-unused-imports #-}
+
 module CLaSH.Tutorial (
   -- * Introduction
   -- $introduction
@@ -459,7 +460,7 @@
 of a <http://en.wikipedia.org/wiki/VHDL VHDL> netlist, from our sequential
 circuit specification. The first thing we have to do is create a function
 called 'topEntity' and ensure that it has a __monomorphic__ type. In our case
-that means that we have to give it an explicit type annotation. It might now
+that means that we have to give it an explicit type annotation. It might not
 always be needed, you can always check the type with the @:t@ command and see
 if the function is monomorphic:
 
@@ -1023,11 +1024,11 @@
 /template/, meaning that the compiler must fill in the holes heralded by the
 tilde (~). Here:
 
-  * @~ARG[1]@ denotes the second argument given to the @timesS@ function, which
+  * @~ARG[1]@ denotes the second argument given to the @(*#)@ function, which
     corresponds to the LHS of the ('*') operator.
-  * @~ARG[2]@ denotes the third argument given to the @timesS@ function, which
+  * @~ARG[2]@ denotes the third argument given to the @(*#)@ function, which
     corresponds to the RHS of the ('*') operator.
-  * @~LIT[0]@ denotes the first argument given to the @timesS@ function, with
+  * @~LIT[0]@ denotes the first argument given to the @(*#)@ function, with
     the extra condition that it must be a @LIT@eral. If for some reason this
     first argument does not turn out to be a literal then the compiler will
     raise an error. This first arguments corresponds to the \"@'KnownNat' n@\"
@@ -1046,7 +1047,7 @@
 @
 {\-\# NOINLINE blockRam# \#-\}
 -- | blockRAM primitive
-blockRam' :: 'GHC.TypeLits.KnownNat' n
+blockRam# :: 'GHC.TypeLits.KnownNat' n
           => 'SClock' clk       -- ^ \'Clock\' to synchronize to
           -> 'Vec' n a          -- ^ Initial content of the BRAM, also
                               -- determines the size, \@n\@, of the BRAM.
@@ -1059,7 +1060,7 @@
           -> 'Signal'' clk a
           -- ^ Value of the \@blockRAM\@ at address \@r\@ from the previous clock
           -- cycle
-blockRam' clk binit wr rd en din = 'register'' clk undefined dout
+blockRam# clk binit wr rd en din = 'register'' clk undefined dout
   where
     szI  = fromInteger $ 'maxIndex' content
     dout = runST $ do
