Generational behavior for the garbage collector

Same as #5227 but living in this repo & squashed.

Any `if 0` code can be removed now.