Fix freeing of packages.