Refactoring of code for DM limit calculations.