Clean up memory allocation.