More safe memory management in ObjectId