GPII-569: Added check if the preferences object is undefined
Merge remote-tracking branch 'kaspermarkus/GPII-569'

* kaspermarkus/GPII-569:
  GPII-569: Added check if the preferences object is undefined