Improve algorithm to retrieve outputs and logs from temporary or permanent storage.