more changes, based off the leaflet code