Minor code reorganization

Move some of the `xdm` object setup to the top of the file and remove
the unnecessary `merge`.