Converted swap module to C++.