Refactoring the module initialization and adding the $mainPath function to $urlState