Initial checking

Added code from cacheing the mean sample.