Patch to fix the double free exception