Some of the __gc() methods has to be rewritten to be safely callable more than once, since the __close() metamethod may do that, and I'm reusing the __gc() metamethod for __close().