diff --git a/Data/ByteArray/Types.hs b/Data/ByteArray/Types.hs
--- a/Data/ByteArray/Types.hs
+++ b/Data/ByteArray/Types.hs
@@ -22,6 +22,7 @@
 #endif
 #ifdef WITH_FOUNDATION_SUPPORT
 import qualified Foundation as F
+import qualified Foundation.Collection as F
 import qualified Foundation.String as F (toBytes, Encoding(UTF8))
 import qualified Foundation.Array.Internal as F
 #endif
@@ -60,4 +61,11 @@
 instance ByteArrayAccess F.String where
     length = F.length
     withByteArray s f = withByteArray (F.toBytes F.UTF8 s) f
+
+instance (Ord ty, F.PrimType ty) => ByteArray (F.UArray ty) where
+    allocRet sz f = do
+        mba <- F.new (F.Size sz)
+        a   <- F.withMutablePtr mba (f . castPtr)
+        ba  <- F.unsafeFreeze mba
+        return (a, ba)
 #endif
diff --git a/Data/Memory/PtrMethods.hs b/Data/Memory/PtrMethods.hs
--- a/Data/Memory/PtrMethods.hs
+++ b/Data/Memory/PtrMethods.hs
@@ -24,7 +24,7 @@
 
 import           Data.Memory.Internal.Imports
 import           Foreign.Ptr              (Ptr, plusPtr)
-import           Foreign.Storable         (peek, poke, pokeByteOff, peekByteOff)
+import           Foreign.Storable         (peek, poke, peekByteOff)
 import           Foreign.C.Types
 import           Foreign.Marshal.Alloc    (allocaBytesAligned)
 import           Data.Bits                ((.|.), xor)
@@ -48,13 +48,19 @@
 --
 -- d = replicate (sizeof s) v `xor` s
 memXorWith :: Ptr Word8 -> Word8 -> Ptr Word8 -> Int -> IO ()
-memXorWith d v s n = loop 0
+memXorWith destination !v source bytes
+    | destination == source = loopInplace source bytes
+    | otherwise             = loop destination source bytes
   where
-    loop i
-        | i == n    = return ()
-        | otherwise = do
-            (xor v <$> peekByteOff s i) >>= pokeByteOff d i
-            loop (i+1)
+    loop _   _  0 = return ()
+    loop !d !s !n = do
+        peek s >>= poke s . xor v
+        loop (d `plusPtr` 1) (s `plusPtr` 1) (n-1)
+
+    loopInplace _   0 = return ()
+    loopInplace !s !n = do
+        peek s >>= poke s . xor v
+        loopInplace (s `plusPtr` 1) (n-1)
 
 -- | Copy a set number of bytes from @src to @dst
 memCopy :: Ptr Word8 -> Ptr Word8 -> Int -> IO ()
diff --git a/memory.cabal b/memory.cabal
--- a/memory.cabal
+++ b/memory.cabal
@@ -1,5 +1,5 @@
 Name:                memory
-Version:             0.14.3
+Version:             0.14.4
 Synopsis:            memory and related abstraction stuff
 Description:
     Chunk of memory, polymorphic byte array management and manipulation
@@ -96,7 +96,7 @@
     Build-depends:   deepseq >= 1.1
   if flag(support_foundation)
     CPP-options:     -DWITH_FOUNDATION_SUPPORT
-    Build-depends:   foundation >= 0.0.4
+    Build-depends:   foundation >= 0.0.8
 
   ghc-options:       -Wall -fwarn-tabs
   default-language:  Haskell2010
