Reapplying fix provided by PR https://github.com/TeamMentor/Dev/pull/143/files to fix https://github.com/TeamMentor/Master/issues/735