Changes some data packing code to do memory allocation in a cleaner way; while I still would like to clean some of the allocation up, it looks like that's going to be complicated in a lot of situations.