Cache number of samples to speed up
Merge branch 'cover' into gb_master