Minor refactoring and clean-up in ModuleLoader.