Refactored module loading code
Minor changes