Fix for incorrect titling in legend when item is single downstream child of aggregation
A bit of refactoring done for the legend generation. A little bit more to go with this
Merge pull request #784 from isuftin/master

Legend fixes/refactoring