merging in jimallmans changes from study-import-options branch of api