Rework modules to inline template for reliable dependency ordering