Extracted the module loading functionality.