setup refactored, main refactored.