.merlin: move the handling in its own module