Structural cleanups and more obsessive error checking.
Hopefully better wall clock timeout enforcement. Not tested.