fix allocation/deallocation mismatch