Why is the third `gc.collect()` call necessary?  (Come to that, why is the second one necessary?)  It would be good to have a comment explaining the multiple `gc.collect` calls.