Initial edit of cachemean.  Function works, but needs comments.