Some logs and refactoring