Skipping zero-length invalid segments in Subpath.addSegment, and adding invalid segment checking