Homoclinic orbits of twist maps and billiards