Updated DM_getdir to work on any system