Refactoring.
Updated logging