Fixes for cov and cor.
Merge branch 'faster-cov'
Merge pull request #2313 from tshort/faster-cov

Fixes for faster cor and cov