Logging and cleanup.