Moved variants code to C++.