Fix legend handling for null