Moved TORQUE foreign function code into module