Make in-place dataset math safer

There is now a defensive deepcopy that makes that variable operations
not really in-place.