More memory optimizations