Cleaned main for factory test