Refactor of logging system