Starting reorganizing the way correlations are calculated. Added new
intermediate functions.