Light refactoring of main.