rewrote some GC code

it was incredible mess, this way it's all much more clean, and hopefuly bit more stable