Fix bug where internal modules were incorrectly being discovered in the module dependency phase