Legend refactoring #283