Minor refactoring to allow redirection of logging