Ported OpenLayers improvements from master.