more dmat refactor