DCS/XRF stable refactored version