Mostly finished refactoring Hex.dm.
Hex.layer_mod may need additional work in the future.