remove redundant memory allocations