Fixed a resource handling bug.