cleaned up the logging and cleaning.