This MR fixes a problem in module instantiation that would occur in very specific setups. Thanks @cjessima for reporting!