Update of KML functions

Multiple tweaks to KML functions, including legends.