fix some memory allocations