Removed dead code and added some logging.