Extracted out module loading functionality.