Some minor clean-up code refactoring.

Refs #6692
Put all the period widgets update code to one function.

Plus minor clean-up/refactoring of the code itself.

Refs #6692
Update widgets only if number of periods has changed.

Refs #6692
Update unconditionally if instrument has changed.

Plus move checks out of the function - more clear that way.

Refs #6692
Merge remote-tracking branch 'origin/feature/6692_muon_save_periods'