Determine max histogram size automatically.
Make sure scratch dir is empty.