Updated for new legend management