Fixing bad deallocation check in generic context