More features for logging. Another major refactor