Now correctly use weighted average to compute the class covariance. Cleaned up code and added references.