Properly deallocate memory passed from cork.

This was a bit of an adventure.