Cleanup of logs and error handling.