Some fixes in GC debugging code

These patches fix some stuff in GC debugging code (activated by uncommenting the `debug = FOO` lines at the top of `gc.d`). I've done them while chasing a memory-corruption bug. I haven't found the bug yet, but these patches are still useful on their own.