Logging and output refactoring