Improvemts to getLegend