Fixed possible loss of resources