diff --git a/cognimeta-utils.cabal b/cognimeta-utils.cabal
--- a/cognimeta-utils.cabal
+++ b/cognimeta-utils.cabal
@@ -1,5 +1,5 @@
 Name: cognimeta-utils
-version: 0.1.1
+version: 0.1.2
 cabal-version: >= 1.8
 build-type: Simple
 license: OtherLicense
@@ -105,7 +105,7 @@
     template-haskell >= 2.7.0.0,
     mtl >= 2.1.2,
     QuickCheck >=2.4.0.1,
-    cognimeta-utils >= 0.1.1,
+    cognimeta-utils >= 0.1.2,
     transformers >= 0.3.0.0,
     bytestring >= 0.9.2.1,
     containers >= 0.4.2.1
diff --git a/src/Cgm/Data/Len.hs b/src/Cgm/Data/Len.hs
--- a/src/Cgm/Data/Len.hs
+++ b/src/Cgm/Data/Len.hs
@@ -119,14 +119,16 @@
 
 refineLen :: forall u v n. (Bits n, LgMultiple u v) => Len u n -> Len v n
 refineLen (Len u) = Len $ u `shiftL` getLgMul (lgMul :: LgMul u v)
-coarsenLen :: forall u v n. (Bits n, LgMultiple v u) => Len u n -> Len v n
+coarsenLen :: forall u v n. (Bits n, Num n, LgMultiple v u) => Len u n -> Len v n
 coarsenLen (Len u) = Len $ ceilDivPower2 (getLgMul (lgMul :: LgMul v u)) u
 
 {-# INLINE coarseRem #-}
-coarseRem ::  forall u v n. (Bits n, LgMultiple v u) => Len u n -> (Len v n, Len u n)
+coarseRem ::  forall u v n. (Bits n, Num n, LgMultiple v u) => Len u n -> (Len v n, Len u n)
 coarseRem (Len u) = let s = getLgMul (lgMul :: LgMul v u) in (Len $ u `shiftR` s, Len $ u .&. ((1 `shiftL` s) - 1))
 
+ceilDivPower2 :: (Num a, Bits a) => Int -> a -> a
 ceilDivPower2 n x = (x + ((1 `shiftL` n) - 1)) `shiftR` n
+roundUpPower2 :: (Num a, Bits a) => Int -> a -> a
 roundUpPower2 n x = ceilDivPower2 n x `shiftL` n
 
 instance Super a b => Super (Len u a) (Len u b) where super = injectionM' (inv struct) . super . injectionM' struct
diff --git a/src/Cgm/System/Endian.hs b/src/Cgm/System/Endian.hs
--- a/src/Cgm/System/Endian.hs
+++ b/src/Cgm/System/Endian.hs
@@ -42,7 +42,7 @@
 import Cgm.Control.InFunctor
 import Cgm.Control.Combinators
 
-class (Prim w, Bits w) => Endian w where 
+class (Prim w, Bits w, Num w) => Endian w where 
   untypedSwapBytes :: w -> w
 
 instance Endian Word8 where 
@@ -64,16 +64,17 @@
 
 {-# INLINE swapHalves #-} 
 swapHalves :: forall w. Bits w => w -> w
-swapHalves w = w `shiftR` halfBitSize + w `shiftL` halfBitSize where
+swapHalves w = w `shiftR` halfBitSize .|. w `shiftL` halfBitSize where
   halfBitSize = bitSize (undefined :: w) `div` 2
 
+-- | Exchange bits in mask with bits at some specified relative position (the last bits must not be in the mask)
 {-# INLINE swapMask #-} 
 swapMask :: Bits w => w -> Int -> w -> w
-swapMask mask shift w = ((w `shiftR` shift) .&. mask) + ((w .&. mask) `shiftL` shift)
+swapMask mask shift w = ((w `shiftR` shift) .&. mask) .|. ((w .&. mask) `shiftL` shift)
 
--- Number with byte value n in the nth byte, in order of increasing significance (starting at 0)
+-- | Number with byte value n in the nth byte, in order of increasing significance (starting at 0)
 byteNumbers :: forall w. Endian w => w
-byteNumbers = sum $ fmap (\n -> fromIntegral n `shiftL` (8 * fromIntegral n)) $ (at :: At w) increasingBytes
+byteNumbers = foldr (.|.) 0 $ fmap (\n -> fromIntegral n `shiftL` (8 * fromIntegral n)) $ (at :: At w) increasingBytes
 
 increasingBytes :: forall w. Prim w => Tagged w [Word8]
 increasingBytes = Tagged $ range (0, fromIntegral (primSizeOf (undefined :: w)) - 1)
