Refactor deletion of resources