Setup logging.
Code refactoring