logger and some refactors