Partially fixed garbage collection.

It still doesn't work fully, but at least it's not as broken as before.
Continued debugging garbage collection.