Move this to where the latest consensus indicates it should go.
Also, integrate some fixes from Christos.
Ditto.