GCP-6859 Fix missing study details bug. Also reorganized some code.