CSS and JS fixes for legend