fixed a memory leak and a race affecting deferred deallocation