Make Xdm class and extract functions