Fixed race condition when serializing weak referenced objects.