Fix infinite loop in KML creation, and reduce disc space