More careful about memory allocations