Refactored Module loading code.