Optimizations to lower memory usage