Patch for Issue #21:
possible endless loop with gc() call