This has an impact on related objects, like timeperiod ranges fixes #2525
This removes duplicate code, fixes some issues introduced with UUIDs and does some cleanup fixes #2415 fixes #2442