Refactor logic for course-related redundant data

Change-Id: Ib5321619226dfb479000aec5eb88592ea50eeb44
Maintenance script for repairing redundant data

Change-Id: I632a32650545153082f33e522cc30e744cce6577
Merge "Refactor logic for course-related redundant data"
Merge "Maintenance script for repairing redundant data"