Refactoring main method. Nothing big.