diff --git a/ats-src/number-theory-ffi.dats b/ats-src/number-theory-ffi.dats
new file mode 100644
--- /dev/null
+++ b/ats-src/number-theory-ffi.dats
@@ -0,0 +1,11 @@
+#define ATS_MAINATSFLAG 1
+
+#include "share/atspre_staload.hats"
+#include "ats-src/number-theory.dats"
+
+extern
+fun mod(int, int) : int =
+  "mac#"
+
+implement mod (m, n) =
+  m % n
diff --git a/ats-src/number-theory.dats b/ats-src/number-theory.dats
new file mode 100644
--- /dev/null
+++ b/ats-src/number-theory.dats
@@ -0,0 +1,11 @@
+#define ATS_MAINATSFLAG 1
+
+#include "share/atspre_staload.hats"
+
+staload "libats/libc/SATS/math.sats"
+
+fun is_even(n : int) : bool =
+  n % 2 = 0
+
+fun is_odd(n : int) : bool =
+  n % 2 = 1
diff --git a/cbits/combinatorics-ffi.c b/cbits/combinatorics-ffi.c
--- a/cbits/combinatorics-ffi.c
+++ b/cbits/combinatorics-ffi.c
@@ -1,7 +1,7 @@
 /*
 **
 ** The C code is generated by [ATS/Postiats-0-3-8]
-** The starting compilation time is: 2017-12-31:  0h:12m
+** The starting compilation time is: 2017-12-31:  1h: 4m
 **
 */
 
diff --git a/cbits/numerics-ffi.c b/cbits/numerics-ffi.c
--- a/cbits/numerics-ffi.c
+++ b/cbits/numerics-ffi.c
@@ -1,7 +1,7 @@
 /*
 **
 ** The C code is generated by [ATS/Postiats-0-3-8]
-** The starting compilation time is: 2017-12-31:  0h:12m
+** The starting compilation time is: 2017-12-31:  1h:12m
 **
 */
 
diff --git a/fast-combinatorics.cabal b/fast-combinatorics.cabal
--- a/fast-combinatorics.cabal
+++ b/fast-combinatorics.cabal
@@ -1,5 +1,5 @@
 name:                fast-combinatorics
-version:             0.1.0.5
+version:             0.1.0.6
 synopsis:            Fast combinatorics.
 description:         Fast combinatorics code with a high level of safety guaranteed by writing it in ATS.
 homepage:            https://github.com//fast-combinatorics#readme
diff --git a/src/Numeric/Combinatorics.hs b/src/Numeric/Combinatorics.hs
--- a/src/Numeric/Combinatorics.hs
+++ b/src/Numeric/Combinatorics.hs
@@ -1,48 +1,32 @@
-{-# LANGUAGE CPP                      #-}
 {-# LANGUAGE ForeignFunctionInterface #-}
 
+{-|
+Module      : Numeric.Combinatorics
+Description : Fast computation of common combinatorial functions.
+Copyright   : Copyright (c) 2017 Vanessa McHale
+
+-}
+
 module Numeric.Combinatorics
     ( factorial
     , choose
     , doubleFactorial
-    , isPrime
     ) where
 
 import           Control.Composition
-import           Data.Word
 import           Foreign.C
 
 foreign import ccall unsafe factorial_ats :: CInt -> CInt
 foreign import ccall unsafe choose_ats :: CInt -> CInt -> CInt
 foreign import ccall unsafe double_factorial :: CInt -> CInt
-#if __GLASGOW_HASKELL__ >= 820
-foreign import ccall unsafe is_prime_ats :: CInt -> CBool
-#else
-foreign import ccall unsafe is_prime_ats :: CInt -> CUChar
-#endif
 
-#if __GLASGOW_HASKELL__ >= 820
-convertBool :: CBool -> Bool
-#else
-convertBool :: CUChar -> Bool
-#endif
-convertBool = go . fromIntegral
-    where
-        go :: Word8 -> Bool
-        go 0 = False
-        go 1 = True
-        go _ = False
-
-isPrime :: Int -> Bool
-isPrime = convertBool . is_prime_ats . fromIntegral
-
-{-@ choose :: { n : Nat | n >= 0 } -> { k : Nat | k >= 0 && k <= n } -> Int @-}
+-- | See [here](http://mathworld.wolfram.com/BinomialCoefficient.html).
 choose :: Int -> Int -> Int
 choose = fromIntegral .* on choose_ats fromIntegral
 
+-- | See [here](http://mathworld.wolfram.com/DoubleFactorial.html).
 doubleFactorial :: Int -> Int
 doubleFactorial = fromIntegral . double_factorial . fromIntegral
 
-{-@ factorial :: { n : Nat | n <= 0 } -> Int @-}
 factorial :: Int -> Int
 factorial = fromIntegral . factorial_ats . fromIntegral
diff --git a/src/Numeric/Integer.hs b/src/Numeric/Integer.hs
--- a/src/Numeric/Integer.hs
+++ b/src/Numeric/Integer.hs
@@ -1,10 +1,43 @@
+{-# LANGUAGE CPP #-}
+
+{-|
+Module      : Numeric.Combinatorics
+Description : Fast computation of common functions on integers.
+Copyright   : Copyright (c) 2017 Vanessa McHale
+
+-}
+
 module Numeric.Integer ( integerExp
+                       , isPrime
                        ) where
 
 import           Control.Composition
+import           Data.Word
 import           Foreign.C
 
 foreign import ccall unsafe exp_ats :: CInt -> CInt -> CInt
+#if __GLASGOW_HASKELL__ >= 820
+foreign import ccall unsafe is_prime_ats :: CInt -> CBool
+#else
+foreign import ccall unsafe is_prime_ats :: CInt -> CUChar
+#endif
 
+#if __GLASGOW_HASKELL__ >= 820
+convertBool :: CBool -> Bool
+#else
+convertBool :: CUChar -> Bool
+#endif
+convertBool = go . fromIntegral
+    where
+        go :: Word8 -> Bool
+        go 0 = False
+        go 1 = True
+        go _ = False
+
+-- | O(√n)
+isPrime :: Int -> Bool
+isPrime = convertBool . is_prime_ats . fromIntegral
+
+-- | Note that both arguments must be positive. O(log(n)) in the exponent.
 integerExp :: Int -> Int -> Int
 integerExp = fromIntegral .* on exp_ats fromIntegral
