bug fix plus changes to the legend.