This makes the function kind of long and sprawling (although admittedly a lot of the line count is comments). Wouldn't it be better to move the invocation of the module closure to another function (maybe inside the module class)?