Optimize memory usage.