A sketch of an implementation.