diff --git a/CHANGELOG.md b/CHANGELOG.md
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,9 @@
 # Changelog for the [`clash-vhdl`](http://hackage.haskell.org/package/clash-vhdl) package
 
+## 0.5.12 *September 21st 2015*
+* Fixes bugs:
+  * Fix Index maxBound [#79](https://github.com/clash-lang/clash-compiler/pull/79)
+
 ## 0.5.11 *September 14th 2015*
 * Support for clash-lib-0.5.12
 * Fixes bugs:
diff --git a/clash-vhdl.cabal b/clash-vhdl.cabal
--- a/clash-vhdl.cabal
+++ b/clash-vhdl.cabal
@@ -1,5 +1,5 @@
 Name:                 clash-vhdl
-Version:              0.5.11
+Version:              0.5.12
 Synopsis:             CAES Language for Synchronous Hardware - VHDL backend
 Description:
   CλaSH (pronounced ‘clash’) is a functional hardware description language that
diff --git a/primitives/CLaSH.Sized.Internal.Index.json b/primitives/CLaSH.Sized.Internal.Index.json
--- a/primitives/CLaSH.Sized.Internal.Index.json
+++ b/primitives/CLaSH.Sized.Internal.Index.json
@@ -37,7 +37,7 @@
 , { "BlackBox" :
     { "name"      : "CLaSH.Sized.Internal.Index.maxBound#"
     , "type"      : "maxBound# :: KnownNat n => Index n"
-    , "templateE" : "to_unsigned(max(0,~LIT[0]-1),~RESULT'length);"
+    , "templateE" : "to_unsigned(max(0,~LIT[0]-1),~SIZE[~TYPO])"
     }
   }
 , { "BlackBox" :
@@ -61,7 +61,7 @@
 , { "BlackBox" :
     { "name"      : "CLaSH.Sized.Internal.Index.fromInteger#"
     , "type"      : "fromInteger# :: KnownNat n => Integer -> Index n"
-    , "templateE" : "to_unsigned(~ARG[1],integer(ceil(log2(real(max(2,~LIT[0]))))))"
+    , "templateE" : "to_unsigned(~ARG[1],~SIZE[~TYPO])"
     }
   }
 , { "BlackBox" :
