pack-objects.c: fix some global variable abuse and memory leaks