Tidy up some memory allocations