Refactoring Logging logic & Code Cleanup