Updated zero counting method and centroid error calculation, again.