added some logging, some cleaning refactoring