GC fix and refactoring