Fixed a few bugs in the garbage collection code.