Rewrite gc() with simple mark&sweep GC