memory usage improvements