WIP: better organization to match dmat