Partial refactoring of main was done.