Some log refactoring