Yet another rebase of Xavier's rng pull request

Because somebody done changed a bunch of stuff in `dbm/__init__.py`.

Fixes #165.
Fixes #376.