Moved m3d instantiation code to m3d.cpp.