Final fix for midpoint bug.