Several fixes for MongoState.