added gc() calls