Checking for garbage collection, fixes #1