Added auto-transaction support

Can arrange for a transaction to be run whenever the boxes it read last
time it ran change.
Also some refactoring to make default implementation neater.
Demos of auto transaction, one of which shows new "fail early"
transaction method, allowing a long-running transaction to check
whether it would currently succeed, and abort if not.