Better handle legend creation and lifecycle
Cosmetic changes