Partial sample calculation. Some kludges left in, I'm not 100% happy with it. Better than before, but not perfect.