Optimize memory consumption