Added legend example + small refactoring.