Fix crashing when adding or updating datasets.