CSHARP-797: Rebased on master.