Refactor parts of DenseM to use helpers
File cleanup to keep eslint happier