Improvements to corrmat function