Fixing a bug when periodicity is used.

The bug caused to not take segments into account that are on the other
side of the periodic boundary. Thus the volume would be wrong.