Add extra segment marker. Remove redundant Math.max