MXD is a new least-squares program for non-standard crystallographic refinement. It uses an original procedure of formula management that is derived from up-to-date compiler programming techniques. While still offering all the least-squares possibilities of most traditional programs, e.g. SHELX, SDP, XRAY etc., MXD has been fully designed for complex crystallographic, magnetic and/or modulated structure refinement. The user enters all the specific formulae describing his own problem into the input data file. Thus, MXD is very convenient when dealing with very complex problems including fitting of modulated structures (magnetic and/or charge density wave), twin or magnetic domain distribution and severe secondary extinction correction. Moreover, if the experimental data are accurate enough (especially from using polarized neutrons), form-factor fitting is accessible. Independently collected data, using various wavelengths, powder or/and single-crystal data, polarized and unpolarized neutron information etc., can be treated simultaneously.