diff --git a/Data/ByteString/Base64.hs b/Data/ByteString/Base64.hs
--- a/Data/ByteString/Base64.hs
+++ b/Data/ByteString/Base64.hs
@@ -23,11 +23,10 @@
 import qualified Data.ByteString as B
 import Data.ByteString.Internal (ByteString(..), mallocByteString, memcpy,
                                  unsafeCreate)
-import Data.ByteString.Unsafe (unsafeIndex)
 import Data.Word (Word8, Word16, Word32)
-import Foreign.ForeignPtr (ForeignPtr, mallocForeignPtrArray, withForeignPtr)
+import Foreign.ForeignPtr (ForeignPtr, withForeignPtr, castForeignPtr)
 import Foreign.Ptr (Ptr, castPtr, minusPtr, plusPtr)
-import Foreign.Storable (peek, peekElemOff, poke, pokeElemOff)
+import Foreign.Storable (peek, peekElemOff, poke)
 import System.IO.Unsafe (unsafePerformIO)
 
 peek8 :: Ptr Word8 -> IO Word8
@@ -228,14 +227,16 @@
 alphabet@(PS alfaFP _ _) = B.pack $ [65..90] ++ [97..122] ++ [48..57] ++ [43,47]
 {-# NOINLINE alphabet #-}
 
+-- The encoding table is constructed such that the expansion of a 12bit block
+-- to a 16bit block can be done by a single Word16 copy from the correspoding
+-- table entry to the target address. The 16bit blocks are stored in big-endian
+-- order, as the indices into the table are built in big-endian order.
 encodeTable :: ForeignPtr Word16
-encodeTable = unsafePerformIO $ do
-  fp <- mallocForeignPtrArray 4096
-  let ix = fromIntegral . unsafeIndex alphabet
-  withForeignPtr fp $ \p ->
-    sequence_ [ pokeElemOff p (j*64+k) ((ix k `shiftL` 8) .|. ix j)
-                | j <- [0..64], k <- [0..64] ]
-  return fp
+encodeTable = 
+    case table of PS fp _ _ -> castForeignPtr fp
+  where
+    ix    = fromIntegral . B.index alphabet
+    table = B.pack $ concat $ [ [ix j, ix k] | j <- [0..63], k <- [0..63] ]
 {-# NOINLINE encodeTable #-}
 
 decodeFP :: ForeignPtr Word8
diff --git a/README.markdown b/README.markdown
--- a/README.markdown
+++ b/README.markdown
@@ -18,15 +18,15 @@
 # Get involved!
 
 Please report bugs via the
-[bitbucket issue tracker](http://bitbucket.org/bos/base64-bytestring).
+[github issue tracker](https://github.com/bos/base64-bytestring).
 
-Master [Mercurial repository](http://bitbucket.org/bos/base64-bytestring):
+Master [git repository](https://github.com/bos/base64-bytestring):
 
-* `hg clone http://bitbucket.org/bos/base64-bytestring`
+* `git clone git://github.com/bos/base64-bytestring.git`
 
-There's also a [git mirror](http://github.com/bos/base64-bytestring):
+And a [Mercurial mirror](https://bitbucket.org/bos/base64-bytestring):
 
-* `git clone git://github.com/bos/base64-bytestring.git`
+* `hg clone https://bitbucket.org/bos/base64-bytestring`
 
 (You can create and contribute changes using either Mercurial or git.)
 
diff --git a/base64-bytestring.cabal b/base64-bytestring.cabal
--- a/base64-bytestring.cabal
+++ b/base64-bytestring.cabal
@@ -1,9 +1,9 @@
 name:                base64-bytestring
-version:             0.1.0.2
+version:             0.1.0.3
 synopsis:            Fast base64 encoding and deconding for ByteStrings
 description:         Fast base64 encoding and deconding for ByteStrings
-homepage:            http://bitbucket.org/bos/base64-bytestring
-bug-reports:         http://bitbucket.org/bos/base64-bytestring/issues
+homepage:            https://github.com/bos/base64-bytestring
+bug-reports:         https://github.com/bos/base64-bytestring/issues
 license:             BSD3
 license-file:        LICENSE
 author:              Bryan O'Sullivan <bos@serpentine.com>
@@ -28,6 +28,10 @@
 
   ghc-options: -Wall -funbox-strict-fields
   ghc-prof-options: -auto-all
+
+source-repository head
+  type:     git
+  location: http://github.com/bos/base64-bytestring
 
 source-repository head
   type:     mercurial
