Refactored and improved module structure