Try cleaning-up the module with templates.

I'm not sure about this, but it saves a few lines and is still pretty
easy to understand, while having no runtime cost.