     let _n = modinv(U(UIntMax(fft_length)), mod)
     for _ in 0..<fft_length {
         let _s = _signal.memory
-        let _k = (_kernel.memory * _n) % mod
-        _kernel.memory = (_s * _k) % mod
+        let _k = mulmod(_kernel.memory, _n, mod)
+        _kernel.memory = mulmod(_s, _k, mod)
         _signal += out_stride
         _kernel += temp_stride
     }

    var input = input
    var output = output
    
    let a = input.memory % mod
    input += in_stride
    
    let b = input.memory % mod
    
    output.memory = addmod(a, b, mod)
    output += out_stride
    
    output.memory = addmod(a, ((alpha % mod) * 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 _n = modinv(U(UIntMax(fft_length)), mod)
    for _ in 0..<fft_length {
        let _s = _signal.memory
        let _k = mulmod(_kernel.memory, _n, mod)
        _kernel.memory = mulmod(_s, _k, mod)
        _signal += out_stride
        _kernel += temp_stride
    }
