Added logging and more refactoring