Legend fixes/refactoring