Refactor second pass

OK this should be already to add some logging.