Rework of some ProgramStats stuff

This is largely prep work for emitting stats via the logger at regular
intervals.