Enhance logging, minor refactorings