Fix resource handling