Fix memory usage