Main module refactored