Improve temporary resource handling