Now matches Python API semantics in corresponding branch. All tests pass.