Refactor so DSMs can be implemented by external packages