ENH: reorg more carefully based on dmat + make clearer variable names + check dimensionality of images