Tickets/dm 1662

This one become even more complex to understand, but it's not blocking.