Deconstructing the Bakery to Build a Distributed State Machine