Fix a crash that could happen due to unpackagedBuffer_ ptr being incremented; when it was free'd and didn't point to the original location, it blows up. Also fix a few more leaks.