Implementation of garbage collector