added dynamic GC for function variables