Prevent memory issue when downloading files