Fix middleware order in CMS.

   And include Don's fix for partial course_id lookup.