     var input = input
     var output = output
     
-    let a = input.memory % mod
-    input += in_stride
-    
-    let b = input.memory % mod
+    let a = input.memory
+    input += in_stride
+    
+    let b = input.memory
     
     output.memory = addmod(a, b, mod)
     output += out_stride
     
-    output.memory = addmod(a, ((alpha % mod) * b) % mod, mod)
+    output.memory = addmod(a, mulmod(alpha, b, mod), mod)
 }
 
 public func NumberTheoreticTransform<U: UnsignedIntegerType>(level: Int, _ input: UnsafePointer<U>, _ in_stride: Int, _ alpha: U, _ mod: U, _ output: UnsafeMutablePointer<U>, _ out_stride: Int) {

        let _alpha_k = pow(alpha, U(UIntMax(half)), mod)
        for _ in 0..<half {
            let tpr = op.memory
            let tphr = (_alpha * oph.memory) % mod
            op.memory = addmod(tpr, tphr, mod)
            oph.memory = addmod(tpr, (_alpha_k * tphr) % mod, mod)
            _alpha = (_alpha * alpha) % mod
            op += out_stride
            oph += out_stride
        }

        let _alpha_k = modinv(pow(alpha, U(UIntMax(half)), mod), mod)
        for _ in 0..<half {
            let tpr = op.memory
            let tphr = mulmod(_alpha, oph.memory, mod)
            op.memory = addmod(tpr, tphr, mod)
            oph.memory = addmod(tpr, mulmod(_alpha_k, tphr, mod), mod)
            _alpha = mulmod(_alpha, _inverse_alpha, mod)
            op += out_stride
            oph += out_stride
        }
