Corrects 'legend' issue and makes other improvements