Optimized memory usage and performance