Trying to optimize allocations and deallocations.