        {
          :nrLessonGroups (integer representing the number of lesson groups
                           occupying the current row)
-         :occupied       (a vector of timeslots from 0800 to 2330 (inclusive)
-                          in 30 min intervals. Each slot is a boolean value.
-                          A value of `True` indicates that the slot is occupied.
-                          A value of `False` indicates that the slot is free.)
+         :occupied        a vector of timeslots from 0800 to 2330 (inclusive)
+                          in 30 min intervals. Each slot is one of:
+                          - nil. The means that the slot is free
+                          - a map of module information:
+                            {
+                              :moduleCode -> module code string
+                              :lessonType -> lesson type string (long form),
+                              :lessonGroup -> Lesson group string (lesson label)
+                              :index       -> index to the list of lessons for
+                                              that lesson group.
+                            }
+                            This information can be used to access the <div> in
+                            the `ModulesSelected` global during module removal
+                            or lesson shifting.
        }"
   []
   {

(defn- timetable-mark-lesson-slots-occupied
  "Given a 0-indexed row number obtained by `find-free-row-for-lesson`, marks
   the timeslots for the lesson in that row as occupied."
  [rowNum lesson]
  (let [day       (:day lesson)
        startTime (:startTime lesson)
        endTime   (:endTime lesson)]
    (set! Timetable
          (update-in Timetable [day rowNum]
                     (fn [ttRow]
                       {
                         :nrLessonGroups (inc (:nrLessonGroups ttRow))
                         :occupied       (reduce (fn [occupiedVec idx]
                                                   (assoc occupiedVec idx true))
                                                 (:occupied ttRow)
                                                 (range startTime endTime))
                       })))))

(defn- find-free-row-for-lesson
  "Returns the 0-indexed row which can accomodate the given lesson (timeslots

    ; Create new row if necessary
    (if (= rowNum (get-nr-rows-in-timetable-day day))
        (add-new-row-to-timetable-day day))

    ; Update in-memory representation of timetable
    (timetable-mark-lesson-slots-occupied
      day rowNum startTime endTime
      {:moduleCode moduleCode, :lessonType lessonType, :lessonGroup lessonLabel,
       :index lessonIdx})

    ; add background color css class
    (.addClass divElem bgColorCssClass)
