moved gc() to free memory earlier in YX.part1