                                           :rowNum)))
 
       (doseq [augTTLessonInfo Lessons-Created-By-Draggable]
-        (let [$divElem  (:divElem augTTLessonInfo)
-              $parentTd (parent $divElem)]
-          ; TODO: This part of the code is the same as in the
-          ;       `remove-lesson-group-html` function. Refactor it.
-          (remove-attr $parentTd "colspan")
-          (.remove $divElem)
-          (add-missing-td-elements-replacing-lesson $parentTd augTTLessonInfo)))
+        (let [$divElem  (:divElem augTTLessonInfo)]
+          ($lesson-div-remove $divElem (:startTime augTTLessonInfo)
+                              (:endTime augTTLessonInfo))))
 
       (timetable-prune-empty-rows affectedDaysSet)
       (set! Lessons-Created-By-Draggable nil)

    ; restore the colspan of the source <td>
    (remove-attr $sourceTd "colspan")
    ; fill in removed <td> for the source <td>
    (add-missing-td-elements-replacing-lesson $sourceTd augTTLessonInfo)
    ; remove sibling <td> for the destination <td> to make way for columns
    ; occupied by $divElem
    (doseq [$siblingTd (take (dec slotsOccupied) (.nextAll $destTd))]

                   notSelectedLessonGroups)))]
      (set! Lessons-Created-By-Draggable augmentedTTLessonInfoSeq))))

(defn- $lesson-div-remove
  "Removes the <div> object of a lesson module, and replaces the former
   columns occupied by its parent <td> with new <td> elements."
  [$lessonDiv startTime endTime]
  (let [$parentTd (parent $lessonDiv)]
    (remove-attr $parentTd "colspan")
    (.remove $lessonDiv)
    (add-missing-td-elements-replacing-lesson $parentTd startTime endTime)))

(defn- lesson-draggable-stop-evt-handler-maker
  "Returns a function used as the `stop` event handler for a draggable lesson."
  [moduleCode lessonType lessonGroup bgColorCssClass]
