Fix bug: orphaned courses and units not being handled correctly.