Change errors that are really logic errors into InternalError
Notice and error in a case a callback overwrites the local PRNG while it's being established (we don't do this anywhere but in the future someone might accidentally)
Factor out some common code
Rewrite stuff for legibility (especially the reentry-prevention code which was hard to follow)
Mostly minor stuff:
No functional (or at least observable) change.