Tightened up tutorial code.