More refinements and a "SampleMain".