Fixed a minor bug in the CentroidEnergy function.