Memory usage improvements